I'm building a website with HTML and CSS. I'm trying to make 4 images contained in a white rectangle, and when those images get clicked it takes you to another part of the page.
Unfortunately, only the last of the 4 images actually takes you to the other part of the page. The other 3 can't even be clicked on. If I delete the last image and the div class it's contained in, the "new" last picture will now work even though it did not previously work before.
I'm pretty sure this is a CSS problem, as when I commented out the CSS code of the rectangle div all the images were working links (though they were jumbled up as the CSS code for their parent class was commented out).
This is the CSS code of the rectangle class and the images contained in it:
#rectangle {
background: white;
width: 1000px;
height: 500px;
position: absolute;
left: 500px;
top: 200px;
text-align: center;
}
#rectangle h1 {
font-size: 50px;
position: relative;
top: 10px;
}
#rectangle .hardware {
position: relative;
top: 50px;
right: 340px;
}
#rectangle .software {
position: relative;
bottom: 200px;
right: 100px;
}
#rectangle .config {
position: relative;
bottom: 450px;
left: 120px;
}
#rectangle .code {
position: relative;
bottom: 700px;
left: 350px;
}
<div id="rectangle">
<h1>Welcome to the docs.</h1>
<h3>Learn how to build your own Olympia</h3>
<div class="hardware">
<img src="../assets/img/hardware.png" height="200px" width="200px" />
<p><b>Hardware</b></p>
</div>
<div class="software">
<img src="../assets/img/software.png" height="200px" width="200px" />
<p><b>Software</b></p>
</div>
<div class="config">
<img src="../assets/img/gear.png" height="200px" width="200px" />
<p><b>Config</b></p>
</div>
<div class="code">
<img src="../assets/img/code.png" height="200px" width="200px" />
<p><b>Code</b></p>
</div>
</div>
Any advice? Thank you!
change
position:relative;
with
display:inline-block;
like this:
#rectangle .software {
/* position: relative;*/
display: inline-block;
bottom: 200px;
right: 100px;
}
#rectangle .config {
/* position: relative;*/
display: inline-block;
bottom: 450px;
left: 120px;
}
#rectangle .code {
/* position: relative;*/
display: inline-block;
bottom: 700px;
left: 350px;
}
Just remove text-align: center; property from #rectangle
This happens because the last div covers the others. Therefore when you hover the other boxes, you are actually hovering the div of the last box.
Usually, using the dev tools in google chrome you can see what's happening actually.
Right click -> Inspect
Related
This is what I have:
I want it to be:
Code snippet:
.test0 {
float: left;
width: 0%;
height: 100px;
}
<div class="test0">
<img src="../arrow.png" height="30px" width="100px">
</div>
Really not able to fix this all day.
You can use positioning to achieve this. You need to make the parent div relative and the child have a position of absolute.
See Codepen
CSS
.test0 {
position: relative;
float: left;
width: 0%;
height: 100px;
}
.test0 img {
position: absolute;
left: -20px;
}
I'm creating a quiz editor.
User should be able to put check box on image
I have a div who represent a zone
inside, there is an image
on the image there are check box.
image may have any size, i don't know the size of image
check box should be positioned relative to the image
image should be center on the zone
I need something dynamic, screen should be resizable
i have the following code:
HTML
<div class="boundary" >
<div class="mycomponent">
<div class ="container">
<img style="display: block; max-height: 100%; max-width: 100%; margin-left: auto; margin-right: auto;" src="image.jpg" >
<img style="left: 20.3501%; top: 44.448%; display: block; position: absolute;" id="imgi0" src="uncheck.png">
<img style="left: 52.7185%; top: 35.7171%; position: absolute;" id="imgi1" src="uncheck.png">
<img style="left: 82.0456%; top: 31.3517%; position: absolute;" id="imgi2" src="uncheck.png">
</div>
</div>
</div>
CSS
.boundary
{
left: 0px;
display: block;
position: absolute;
right: 0px;
bottom: 50px;
top: 75px;
background-color: aquamarine;
}
.mycomponent
{
height: 43%;
width: 89.29%;
top: 26.78%;
left: 5.496%;
overflow-y: hidden;
overflow-x: hidden;
position: absolute;
padding: 0px;
text-align: center;
border-color:#000000;
border-style: solid;
background-color: beige;
}
.container
{
display: inline-block;
position: relative;
overflow: hidden;
}
jsfiddle : http://jsfiddle.net/jlogan/91p06yjm/
This code works fine on chrome and safari but failed in firefox and ie9+
any clue ?
Thansk a lot
I updated and cleared your fiddle to make it clearer. You can give your class "mycomponent" max-height instead of height.
.container{
max-height: 43%; // You had "height:43%";
width: 89.29%;
top: 26.78%;
left: 5.496%;
overflow-y: hidden;
overflow-x: hidden;
position: absolute;
padding: 0px;
text-align: center;
border-color:#000000;
border-style: solid;
background-color: beige;
}
Working fiddle
It's working for me in every browser, even if you resize the window.
I'm trying to overlay a transparent image over another via the after property. It's not even showing up using this method. I wanna use a base64 encoded image if at all possible. I tried with a regular non-encoded image too. No dice. Anyone have any thoughts?
My HTML:
<div class="image-container">
<img src="images/sample.jpg" alt="Sample Image" />
</div>
My CSS:
.image-container {
position: relative;
width: 183px;
height: 137px;
overflow: hidden;
}
.image-container img {
position: absolute;
}
.image-container img:after {
display: block;
position: absolute;
margin-top: -50%;
width: 183px;
height: 103px;
content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJAAAACPCAYAAAAVxlL2AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/H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cv/uXnz5lMiOI48DyqewZEHwsOVLDgIlbzJZLLs3r279MqVK6X9+/f3DQ8P782yLEu7q/tYRUXFf9PS0jLmzp37dUlJyXUCPE0qdI8gp3dAQUCjM77SnAtaOiA1P+nxvHnzBi9atGhCbGxsTO/evUMoTPfH6uvrG8rKyiq+++67/C1btpy9detWHbRvkI7vyNYMynNfAigIZmcgkkoHpMk7tApOagYAMERERATOnj170Lhx4x6Mjo7uFxYWFtKrVy8/juM4uu7cfcYwDMPzPG8ymczV1dW1VVVVP58+ffpqVlZW+fHjx29C+x5IJqzJ7Y2k+mBfR2KZBBHujVCPhP7Ug31xPb7cx51rxnrcEI6UUIFCLRcChwQKukOJ0i4l+CJOonEqLxKwFyPuVYhcoA6DR/JccmvF1AJNzX6NltwybgkKCZAWsD+SwdEm6YrwqAGIBJGj8g98KQ/qeRx5HwqQcxDhS755Qp/gO5NYwH7jULlU3aHM4FykHmSoZ6F98yfU6yjBQ6FxD0ikUGZDIMGBUdokXbU+dbbzFNdfg/2qSA0hbOGhiwLUeYiIwyvQcUkOvjuJ7FovV4AAN4LEyAAj53koQO4LZaR1fQKoWCAILlaCdrbzGAdA4WABheee6CG5nUlkN5zoLABuGY5w8icFqOsyMzlI3L4XVFd2IHMP34uaPFBug4Vk/z8A0Bt+GXoiAF0AAAAASUVORK5CYII=) no-repeat;
}
no-repeat is an invalid value for your content property, so it should be
.image-container img:after {
position: absolute;
margin-top: -50%;
width: 183px;
height: 103px;
content: url(#);
}
Also it won't make sense using display: block; on absolute positioned element.
Demo
Also, chrome doesn't understand img:after so better use .image-container:after
Demo 2
I got a weird behaviour on IE8 for this
HTML:
<a class='main'>
<img src='http://annawrites.com/blog/wp-content/uploads/2011/04/color-explosion.jpg' />
<div class='layer'> </div>
</a>
CSS:
.main { display: block; position: relative; width: 100px; height: 100px; }
.main img { width: 100px; height: 100px; /*display: none;*/ }
.layer { position: absolute; top: 0px; left: 0px; width: 100%; height: 50%; cursor: crosshair; }
JSFiddle: http://jsfiddle.net/HLua8/2/ (or open this in IE8)
On IE8, .layer (ie. the crosshair cursor) is only on the top left corner (it minimizes itself to the content, which is 3 x )
I noticed it works fine when I set .main img to display:none but I need the image
Could someone help me to make .layer shown on IE8 as big as it is supposed to be? (ie. 100% width 50% height, just like on other browsers)
After much fiddling, the best solution I could come up with for you, is to create a blank/transparent image and use this as the background image for your layer.
add to your css:
.layer {background-image:url(blank.png);}
.layer:hover{cursor: crosshair;}
an updated version of your document would look as follows:
css:
#container {
margin:40px;
position: relative;
width: 100px;
height: 100px;
}
.main img {
max-width: 100%;
}
.layer {
position: absolute;
top: 0px;left: 0px;
width: 100%;height: 50%;
background-image:url(img/blank.png);
}
.layer:hover{cursor:crosshair;}
html:
<div id="container">
<a class='main' href="test.html"><img src='http://annawrites.com/blog/wp-content/uploads/2011/04/color-explosion.jpg' /></a>
<div class='layer'></div>
</div>
How can I align text to the bottom right of a big <a> element inside a div?
Here is what I have, but I want the text at the bottom of the box. I've searched a lot and nothing has worked for me:
<div class="thumbnail">
Link to somewhere
</div>
with the following css:
.thumbnail{
width: 200px;
height: 200px;}
.thumbnail a{
display: block;
height: 100%;
width: 100%;
text-align: right;
background-color: lightgrey;}
http://jsfiddle.net/8JsPV/
Thank you
I changed your HTML and put the entire thing in an <a> tag so it is all clickable. jsFiddle Here.
HTML:
<div class="thumbnail"><span>Link to somewhere</span></div>
CSS:
.thumbnail{
width: 200px;
height: 200px;
position: relative;
background-color: lightgrey;
}
.thumbnail span{
display: block;
position: absolute;
bottom: 0;
right: 0;
}
EDIT:
To do it WITHOUT putting an div inside the <a>, try this.
This should help if you change the HTML accordingly:
.thumbnail{
position: absolute;
bottom: 0;
right: 0;
}
a{
display: block;
position: relative;
width: 200px;
height: 200px;
background-color: lightgrey;
}
HTML:
<div class="thumbnail">Link to somewhere</div>
Updated fiddle
Try this
.thumbnail
{
position: relative;
width: 200px;
height: 200px;
background-color: Orange;
display: block;
}
.thumbnail span
{
position: absolute;
right: 0px;
bottom: 0px;
display: block;
text-align: right;
background-color: Gray;
}
and change the HTML like so
<a class="thumbnail" href="#"><img
src="http://www.healthfiend.com/wp-content/uploads/2011/01/Facial-Exercises.jpg"
alt="face" /><span>Link to somewhere</span></a>
This makes the whole thing clickable and aligns the text to the bottom right. I replaced you div with an img tag as I assume for a thumbnail this is actually what you probably want in the end. Right?