Hello i have been trying a lot to do the pop-up image effect using CSS and CSS3 but the result is nothing i don't know what is the problem, i think it's because of the pseudo-classes don't work with me like (visited,actived and focus etc..) just hover works with me so could anybody help me solve this problem?
what i mean by pop-up image effect is : you know when clicking on an image on Facebook that image is popped up with it's real size and the background is become a little bit more dark?
By the way does anyone know what is the problem with the pseudo-classes why they don't work with me?
thanks
<style type="text/css">
.pop{
border: 1px solid #000 ;
border-radius: 15%;
width: 200px;
height: 200px;
}
.pop:active{
width:500px ;
height:500px;
position:relative;
right: -65px;
top: 200px ;
background-color:#000;
}
<img class='pop' src="C:/Users/mohammad ghazi/Desktop/Xhtml folder/friends.jpg" alt="" />
What you are looking for is called a lightbox. Their are many good tutorials on how to make a pure css one, here is a few of them:
http://andornagy.com/pure-css-image-lightbox/
http://www.designcouch.com/home/why/2013/11/01/responsive-css3-lightbox-with-no-javascript/
http://www.thecssninja.com/xhtml/futurebox
The problem with using :target as a CSS click event is that it has some downsides such as page jumps or browser history.
You can avoid the downsides of :target by using the checkbox hack:
Make a checkbox and hide it:
<input type="checkbox" id="check" style="display:none;">
Then, make the image you want to have a lightbox for, and wrap it in a <label>
<label for="check">
<img src="http://lorempixel.com/400/400/" width="200">
</label>
Now, write the HTML for the lightbox:
<label for="check">
<div id="cover">
<div id="box">
<img src="http://lorempixel.com/400/400/" width="400">
</div>
</div>
</label>
And now, for the CSS magic!
Create the lightbox css:
#cover{
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
background:rgba(0,0,0,0.5);
display:none;
}
#box{
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
margin:auto;
width:400px;
height:400px;
border:10px solid white;
}
This creates and centers the lightbox.
Now you need to add the click event:
#check:checked ~ label #cover{
display:block;
}
This CSS means, If #check is checked (:checked selector), find the sibling (~) with a id of #cover inside a label element and apply the rule to it.
That's it!
Your coding should look like this:
<input type="checkbox" id="check" style="display:none;">
<label for="check">
<img src="http://lorempixel.com/400/400/" width="200">
</label>
<label for="check">
<div id="cover">
<div id="box">
<img src="http://lorempixel.com/400/400/" width="400">
</div>
</div>
</label>
And CSS:
#check:checked ~ label #cover{
display:block;
}
#cover{
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
background:rgba(0,0,0,0.5);
display:none;
}
#box{
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
margin:auto;
width:400px;
height:400px;
border:10px solid white;
}
SEE THIS JSFIDDLE
I think what you're going for is definitely javascript or Jquery. here is a JSFiddle which shows what i'm on about.
HTML:
<img src="http://0.s3.envato.com/files/19320511/Scenery%2080x80%20Avatar.png"/>
<div id="divLargerImage"></div>
<div id="divOverlay"></div>
JQuery:
$('a img').click(function () {
var $img = $(this);
$('#divLargerImage').html($img.clone().height(250).width(250)).add($('#divOverlay')).fadeIn();
});
$('#divLargerImage').add($('#divOverlay')).click(function () {
$('#divLargerImage').add($('#divOverlay')).fadeOut(function () {
$('#divLargerImage').empty();
});
});
CSS:
#divLargerImage
{
display: none;
width: 250px;
height: 250px;
position: absolute;
top: 35%;
left: 35%;
z-index: 99;
}
#divOverlay
{
display: none;
position: absolute;
top: 0;
left: 0;
background-color: #CCC;
opacity: 0.5;
width: 100%;
height: 100%;
z-index: 98;
}
There are many ways to do this, but most easy way to do this is you can use lighbox tools like: FancyBox, Colorbox plugins etc.
Fancy Box: http://fancybox.net
Color Box: http://www.jacklmoore.com/colorbox/
Alternatively you can use: jQuery Lightbox Generator
jQuery Lightbox Generator: http://visuallightbox.com/
For the problem with pseudo-classes, what i got from your question is you want to enlarge image?
Check this Jsfiddle:
` http://jsfiddle.net/23zgvg1f/1/ `
I hope this helps :)
Related
I would like to be redirected to Google when I click on a picture but it doesnt work. I used <a href="https://www.google.com"> but somehow the it doesnt recognize it. Do you know what the problem is and how to solve it?
HTML
<div class="image-parent">
<div data-content="Go to google" class="image fit">
<img src="https://image.shutterstock.com/image-vector/abstract-orange-linking-dots-background-600w-334647518.jpg" alt="" />
</div>
</div>
CSS
.image:after, .image:before {
position:absolute;
opacity:0;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.image:after {
content:'\A';
width:100%; height:100%;
top:0; left:0;
background:rgba(0,0,0,0.6);
}
.image:before {
content: attr(data-content);
width:100%;
color:#fff;
z-index:1;
padding:30px 30px;
top: 50%;
transform: translateY(-50%);
text-align:center;
background:red;
box-sizing:border-box;
-moz-box-sizing:border-box;
vertical-align: middle;
}
.image:hover:after, .image:hover:before {
opacity:1;
}
DEMO https://jsfiddle.net/5arxwq3k/
Check this Fiddle, The <a> tag is above the div: https://jsfiddle.net/bardalesj/xoLzdem9/
Simply dont put the :after and the :before on the .image class because the one is on your div-element outside the -tag.
put it on the a-tag or the image tag like
.image a:before
The way you have it right now it only extends the styled click area of the div tag which is not part of the link
Do same with the :hover rules and stuff.
Just modify your html and add an onclick listener.
<div class="image-parent">
<div data-content="Go to google" onclick="window.open('https://www.google.com')" class="image fit">
<img src="https://image.shutterstock.com/image-vector/abstract-orange-linking-dots-background-600w-334647518.jpg" alt="" />
</div>
</div>
This solution is an alternative to using a link.
<!DOCTYPE html>
<html>
<head>
<style>
html,body{
height:100%;
width:100%;
margin:0%;
Padding:0%;
}
.wrap{
height:100%;
width:100%;
position:relative;
overflow:hidden;
background:#120103;
color:#fff;
text-align:center;
}
header{
background:#3E474F;
box-shadow:0 .5em 1em #111;
position:absolute;
z-index:900;
width:100%;
}
header label{
color:#788188;
cursor:pointer;
display:inline-block;
line-height:4.25em;
font-size:.667em;
font-weight:bold;
padding:0 1em;
}
header label:hover{
background:#2e353b;
}
.slide{
width:100%;
height:100%;
position:absolute;
top:0%;
left:100%;
z-index:10;
padding:8em 1em 0;
background-color:#120103;
background-position:50% 50%;
background-size:cover;
transition:left 0s .75s;
}
[id^= "slide"]:checked + .slide{
left:0;
z-index:100;
transition:left .65s ease-out;
}
img{
height:250px;
width:250px;
Margin:20px;
Overflow:none;
display:block;
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background-color: #008CBA;
}
.slide-one:hover .overlay{
opacity:0.5;
}
.slide-two:hover .overlay{
opacity:0.5;
}
.slide-three:hover .overlay{
opacity:0.5;
}
.text {
color: white;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.slide-one{
background-image:url('wow.jpg');
}
.slide-two{
background-image:url('Anonymous.jpg ');
}
.slide-three{
background-image:url('1.jpg');
}
</style>
</head>
<body>
<div class="wrap">
<header>
<label for="slide-1-trigger">Slide One</label>
<label for="slide-2-trigger">Slide Two</label>
<label for="slide-3-trigger">Slide Three</label>
</header>
<input id="slide-1-trigger" type="radio" name="slide" checked>
<section class="slide slide-one">
<div class="overlay">
<div class="text">Ethical Hacking is licensed hacking.... Read More
</div>
</div>
</section>
<input id="slide-2-trigger" type="radio" name="slide" >
<section class="slide slide-two" >
<div class='overlay'>
<div class="text">A rather famous group of hackers and tech savvys spread
across the world....Read More</div>
</div>
</section>
<input id="slide-3-trigger" type="radio" name="slide" >
<section class="slide slide-three" >
<div class='overlay'>
<div class="text">Just Checking</div>
</div>
</div>
</body>
</html>
Hello everybody , i was watching a video on making a CSS image slider after watching the whole video i wrote the above code but am having some problem understanding this particular piece of code:
[id^= "slide"]:checked + .slide{
left:0;
z-index:100;
transition:left .65s ease-out;
}
I need help understanding this part of the code. Thank you for help in advance :)
First off it seems you understand the fundamental principles of CSS but if I am wrong and you do not, I recommend the tutorials of MDN about How CSS works and the Syntax.
So piece by piece...
1. [id^= "slide"]:checked + .slide
This is the selector and consists of two major parts: [id^= "slide"]:checked and .slide, connected by a + sign. I assume that you know what .slide means on its own. If not, you should read the articles that I posted above.
1.1. +
The + operator with the x + y syntax selects all elements that would be selected by pure y but it limits the selection to only those elements directly following other elements which would be selected by x. So if you have .a + .b then you get all elements with the class b directly preceded by elements with the class a:
div {
border: 1px dashed black;
padding: 1em;
margin: 1em;
}
.wupwupwup + .nanana {
background: red;
}
This selects all .nanana directly after .wupwupwup.
<div class="nanana wupwupwup">This is not selected because there is no .wupwupwup before.</div>
<div class="wupwupwup">This is not selected because it has no .nanana class</div>
<div class="nanana">This is selected because it has .wupwupwup before and itself matches .nanana</div>
<div>This is not selected because it does not match .nanana and also because the previous element does not match .wupwupwup</div>
1.2. [id^="slide"]:checked
This one again consists of two selectors: [id^="slide"] and :checked. :checked is explained very simply: x:checked selects all elements that match x as long as they are "checked". An element is "checked" for example if it is a checkbox or radio button and is checked. So we now need to examine the x in this case [id^="slide"]. That is a selector which selects all elements which have an attribute id which starts with slide. So it would select all elements with ids like slide, slide-1-trigger, slide-2-trigger, slider, and so on.
So what the whole [id^= "slide"]:checked + .slide does can be explained like this: It selects all elements with the class slide that directly follow a "checked" element with an ID that begins with slide.
In your case ...
... this means, that for example the element <section class="slide slide-one"> after a checked <input id="slide-1-trigger" type="radio" name="slide" checked> will be selected.
2. The rules
{
left:0;
z-index:100;
transition:left .65s ease-out;
}
First off: You can read about transitions on MDN.
What your transition basically does is: Make the change of the property left to the value 0 smooth for 0.65 seconds. While it does this, it subtly uses a special easing function called ease-out but you can omit that probably without noticeable differences. The z-index of 100 makes this current slide the top-most so that it is not hidden behind the other slides.
Another thing ...
... that you may have missed: The <label ...> elements that you use will mark the corresponding <input ...> elements as checked if you click on the labels. That is why their state changes and then the :checked selector takes effect.
:checked is a CSS pseudo-class selector that represents any radio, checkbox or option that has been checked/clicked. That segment of CSS is just targeting any id of slide-trigger and performing a transition left when the :checked pseudo-class is active. I hope that was helpful
I have been working with several solutions on the web and have not found anything that works.
I am trying to do something that should be simple. I am trying to have an image of a "button" underneath an actual button. When I do this, the image always overlaps the button itself.
HTML:
<div id="button"> <!-- Container for my image and button -->
<img src="C:\Users\Hansen\Desktop\Websigte\Images\buttonUnclicked.png" />
<input type="button" value="Roofing" onclick="createImageRoof();" style="position: absolute"/>
</div>
CSS:
#button {
height:30px;
padding:3px;
position:relative;
}
input[type=button] {
font: 12px verdana,arial,sans-serif;
width: 86px;
float:left;
z-index:0;
}
Instead of using an actual image (which you won't be able to put behind anything), just make it a background image.
CSS:
#button {
height:30px;
padding:3px;
position:relative;
background: url('file:///C:/Users/Hansen/Desktop/Websigte/Images/buttonUnclicked.png');
background-repeat: no-repeat;
}
input[type=button] {
font: 12px verdana,arial,sans-serif;
width: 86px;
float:left;
z-index:0;
}
jsBin demo
Use a background image for #button if you want
<div id="button">
<input type="button" value="Roofing"/>
</div>
CSS:
#button {
width:90px;
height:30px;
padding:3px;
position:relative;
background: url(Images\buttonUnclicked.png);
}
#button > input {
position:absolute;
left:5px;
top:6px;
width: 86px;
}
If you adjust the number for the left and the top in the CSS, you can move your picture around. I called the picture #myImage in the HTML. Hope that helps.
CSS
#myImage{
position:absolute;
left:10px;
top:50px;
}
#button {
height:30px;
padding:3px;
position:relative;
}
input[type=button] {
font: 12px verdana,arial,sans-serif;
width: 86px;
float:left;
z-index:0;
}
html
<div id="button"> <!-- Container for my image and button -->
<img id="myImage" src="C:\Users\Hansen\Desktop\Websigte\Images\buttonUnclicked.png" />
<input type="button" value="Roofing" onclick="createImageRoof();" style="position: absolute"/>
</div>
Strange issue here which I can't see the problem with! I'm setting the width of the entire element using the class sale_container. But it's width is not changing at all!
See JSFiddle Demo
CSS:
/*Sale styles*/
.add_sales input {
background:none;
border:none;
color:#FFF;
}
.sales_toolbar input {
width:30px;
}
.sale_container {
width:500px;
border:2px solid #FFF;
}
.sale_image {
height:200px;
width:200px;
background-size:cover;
border-radius:10px;
}
.sale_image_container {
border:solid #000 1px;
float:left;
border-radius:10px;
background-color:#353535;
}
.sale_image_container p {
margin:10px;
}
.sales_toolbar {
float:right;
}
HTML:
<form class="add_sales" name="add_sales" action="php/process_sales.php" method="post">
<div class="sale_container">
<div class="sale_image_container">
<div style="background-image:url(data/images/20140121/0/image8.jpg)" class="sale_image"></div>
<p>KR</p>
</div>
<div class="sales_toolbar">
<input type="text" readonly value="KRR" id="50_selected" /> <!-- Selected -->
</div>
</div>
</form>
It seems to be working on the JSFiddle, but when I preview it in Chrome, it looks like this:
It's possible that additional styles are being included from an alternate CSS source. Have you tried using Inspect Element to view the div, and see if it has any unexpected styles being applied? Chrome natively has the feature built-in if you right-click any element.
Glad to help.
Set position to absolute of sale_container to change width.
.sale_container{
width: 300px;
position: absolute;
border: 2px solid #E97676;
}
Use firebug (http://getfirebug.com/) to inspect html element and css attributes.
CSS1 worked:
.parentDisable
{
z-index:2000;
width:100%;
height:100%;
display:none;
position:absolute;
left:0;
background: url(/images/btrans.png) repeat;
color: #aaa;
}
#popup
{
width:300px;
height:auto;
position:absolute;
background-color: whitesmoke;
color: #6699ff;
top:40%;
left: 40%;
}
CSS2 Not worked:
display:none;
z-index:2000;
position: absolute;
width: 100%;
top: 0;
left: 0;
background: #000;
opacity: 0.5;
filter: alpha(opacity=50);
HTML
<div id="pop1" class="parentDisable">
<center>
<div id="popup">
<div id="loading"> </div>
<div id="popupText" align="left"> </div>
<a href="#" onClick="return hidePopup_('pop1')" >
<img style="position: absolute;top: 0;right: 0" alt="close" src="/images/close.png" width="40px" height="40px"/>
</a>
</div>
</center>
</div>
with CSS1 i got this but not full HEIGHT and i want this at current scroll position not at TOP not at BOTTOm
when i click on link my page goes to top and display as in image.
UPDATE1 :
Remaining is not to scroll page up|Top
when i click on link page scroll-up to TOP.
Script :
// set full page height
var hei = document.body.offsetHeight;
$('#pop1').css({height: hei +'px'});
Instead of position: absolute use position: fixed.
To prevent the page from jumping to top you need to include a return false within your javascript-function hidePopup_.
The link trys to jump to the anchor # and since there isn't one, it jumps to the top.
Try using a position:static for .parentDisable. This will generally give you better results for what I think you're looking for.