I'm new at this so bear with me. I have an absolute positioned box inside a relative container and inside that box I've two other divs, one for posts and one for sprites. The sprites completely disappear in IE7 along with the top (and only the top) border on the "posts." This is basically what it looks like.
<div id="wrapper">
<div id="content">
<div id="left"></div>
<div id="right">
<div id="icon">
</div><!--icon-->
<div id="posts">
<div class="posts_border"></div>
<!--a bunch of other stuff-->
<div class="posts_border"></div>
</div>
</div><!--right-->
</div><!--content-->
</div>
#wrapper{width:900px;margin-top:111px;margin-left:-450px;position:relative;left:50%;}
#content{background-color:#F6EFC9; position:relative; width:900px;height:965px;}
#left{padding-right:10px;width:550px;}
#right{position:absolute;top:0;right:20px;width:300px;}
#icon{margin:10px 0 0 -8px;top:0;right:20px;}
#icon .icon{margin-left:40px;width:50px;height:50px;float:left;}
#email{background:url("../images/icon-sprite.png")left 0 top -110px;}
#twitter{background:url("../images/icon-sprite.png") left 0 top -55px;}
#rss{background:url("../images/icon-sprite.png") left 0 top 3px;}
#posts{background:#E3C66E; margin-top:10px;position:absolute;top:66px;}
#right .posts_border{height:20px;background-color:#442503;}
http://jsfiddle.net/isherwood/aJwKJ/
This seems to work in every browser aside from IE7.
I had to do this in IE10 by changing my Browser/Document mode to IE7/IE7 on a local document. I had problems with jsfiddle loading in that browser/doc mode. I only changed the following sections
#email {
background-image: url("http://placehold.it/32x32");
background-position: 0 -110px;
}
#twitter {
background:url("http://placehold.it/32x32");
background-position:0,-55px;
}
#rss {
background:url("http://placehold.it/32x32");
background-position:0,3px;
}
Related
<div class="box">
<div class="top">
</div>
<div class="bottom">
<img src="//placehold.it/300x300">
</div>
</div>
.bottom{
position: absolute;
bottom: 0;
}
I got 2 blocks, top and bottom. In bottom block there is an image that should overlay top block in one place. it overlays Ok but I can't click on element from top block cause browser think i click on bottom. How can it be resolved?
Add
pointer-events : none;
to your .bottom element.
https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
I'm building a random quote generator: http://codepen.io/Kestvir/pen/peqjZZ ,
and while doing the html/css part of things, I've encountered a problem with the content, that is inside the transparent background. When resizing the window, the content is going off to right side, and it no longer looks like it is centered, when it actually is. If I remove the margins of the background (margin: 0 150px;) then this problem no longer exists, but then the transparent background becomes as wide as the entire window. I suspect that this is because my <div class="quote-bckgr"> is outside of the container, but I did so, because I had no idea, how to center my contents with the mentioned div class being inside the container, as opposed, of how it is now, because it was stuck to the very top of the page. How should I fix the text and buttons going off to the right, and not looking centered ?
I think this is what you wanted. I added the margin inside container and row divs, added the background color and border radius and removed it from your other class.
codepen
<body>
<div class="quote-bckgr">
<div class="container">
<div class="row">
<div class="new-margin">
<div class="col-sm-12">
<h1> Welcome to CIV5 random quote generator!</h1>
<div id="quotation"></div>
<div id="author"></div>
</div>
<div class="row">
<div class= "col-md-3 col-md-offset-3">
<i class="fa fa-twitter" aria-hidden="true"></i>Tweet This Quote
</div>
<div class="col-md-3">
New Quote
</div>
</div>
</div>
</div>
</div>
</div>
</body>
and css
.quote-bckgr {
color: #fff;
text-align: center;
position: relative;
top: 50%;
margin: 0 auto;
transform: translatey(-50%);
overflow: hidden;
}
.new-margin{
margin:0 155px;
background-color: rgba(25, 0, 0, .45);
border-radius:5px;
}
This question already has answers here:
What is the use of style="clear:both"?
(3 answers)
Closed 8 years ago.
I was noticing that <div style="clear:both;"></div> had been frequently used in a website between div areas. Given the fact that no other rules such as width and height has been specified for this, what is the effect of this type of usage? an example of the site code follows below
<div id="content">
<div id="middle-cont"></div>
<div id="bot-r">
<div style="clear:both;"></div>
<div class="hwd-module latest-audio"></div>
<div style="clear:both;"></div>
</div>
</div>
<style>
#middle-cont {
padding: 18px 0px;
margin-top: 20px;
margin-right: -40px;
margin-left: -40px;
}
#bot-r, #bot-c, #bot-l {
width: 32%;
height: auto;
float: right;
padding: 5px;
}
</style>
Clear:both
is used to clear any (or for that matter, all preceding) floats.
It basically means "No floating elements allowed on either the left or the right side".
Let us try to understand this with a demonstration :
You can see a couple of examples below:
No clear -> http://jsfiddle.net/0xthns3k/
The html and css are as follows :
HTML :
<div class="left">
</div>
<div class="right">
</div>
<!-- No clear -->
<div class="Green"></div>
CSS :
div {
display:inline-block;
width: 150px;
height:150px;
}
.left {
background-color:Orange;
float:left;
}
.right {
background-color:Red;
float:right;
}
.Green {
background-color:Green;
}
.yellow {
background-color:yellow;
width:30px;
}
This is the image of the generated HTML.
If you see here, the green colored box is placed somewhat in the center of the two floated elements. Well, actually since there are floated elements the new "non-floated" element is actually placed adjacent to the leftmost floated element. Hence, you see the green colored element just adjacent to the leftmost floated element.
Now, if you were to have another element(s) floated left, this would automatically fit between the Orange and the Green elements.
See this below :
http://jsfiddle.net/0xthns3k/1/
Also, the position of this 'new' left floated element wouldn't be that important too with respect to the said HTML.
Placed below green element
<div class="left">
</div>
<div class="right">
</div>
<!-- No clear -->
<div class="Green"></div>
<div class="left yellow">
</div>
Placed after right floated element.
<div class="left">
</div>
<div class="right">
</div>
<div class="left yellow">
</div>
<!-- No clear -->
<div class="Green"></div>
Placed after left floated element
<div class="left">
</div>
<div class="left yellow">
</div>
<div class="right">
</div>
<!-- No clear -->
<div class="Green"></div>
All the above HTML code would generated the same HTML as shown in the image above.
With clear -> http://jsfiddle.net/bk3p160d/
The HTML is only slightly modified here :
HTML
<div class="left">
</div>
<div class="right">
</div>
<div class="clearAll"></div>
<div class="Green"></div>
and one additional CSS class :
CSS
.clearAll {
clear:both;
}
If you see here, the green colored element is positioned below the line containing the aforementioned floats. This is because "clear: both" tells the HTML rendering engine
"No floating elements allowed on either the left or the right side". Hence, it cannot place this element on the same line as it would violate the defination. This causes the engine to place it on a new line. On the line the preceding float properties are essentially nullified. Hence, clear:both is used to effectively clear any preceding floats.
See here for further information : http://www.w3schools.com/cssref/pr_class_clear.asp
Hope this helps!!!
I would like to write up some css/html for container boxes that I can put on my site in various places (ie- to draw out modules like a calendar on the site's sidebar).
I have 5 images: left, right, top, bottom and background for the div.
The top image is 37 px tall, the bottom image is 22 px tall.
I would ideally like to specify a div height/width and then have it draw the div with the images on the top/bottom/right/left sides, autosized to the div's proportions and not overlapping with each other. I would assume that youd want to use absolute positioning for the non-overlapping bit, but I'm completely unsure of how to make the images resize and stick to each side.
Here's the (very bare) code that I have right now:
#top {background: url(container_top.png) no-repeat;}
#container {background: url(container_left.png) no-repeat;}
#right {background: url(container_right.png) no-repeat;}
#bottom {background: url(container_bottom.png) no-repeat;}
<div id="top">
<div id="container">
Content post
</div>
<div id="right"></div>
<div id="bottom"></div>
</div>
The only other caveat is that I only want the top/bottom images to scale horizontally (not to resize on the y axis as well), and the left/right images to scale vertically (not to resize on the x axis as well).
For reference, my images are named:
"container_.png"
there are a few options. First one is to create four corner divs and four side divs, using the corner images at each corner and a repeatable image for the sides. You can also use a kind of "sliding-door" technique. And if you're a brave guy, use css3 border-images (checkout http://w3schools.com/cssref/css3_pr_border-image.asp)
option one:
<div class="box">
<div class="top">
<div class="top-left"></div>
<div class="top-right"></div>
</div>
<div class="content">
<div class="left"></div>
<div class="content">Lorem ipsum dolor sit amet</div>
<div class="right"></div>
</div>
<div class="bottom">
<div class="bottom-left"></div>
<div class="bottom-right"></div>
</div>
</div>
.top { background: url('repeatable.png') repeat-x; }
.top-left { background: url('top-left.png') no-repeat; }
.content .left { background: url('repeatable') repeat-y; }
....
for sliding door technique, checkout http://www.google.com/?q=google+css+sliding+doors
EDIT: This happens only in IE8, it works fine in IE7, Firefox, Opera etc
First of all, here is a picture I have made in photoshop to demonstrate my problem: http://richardknop.com/pict.jpg
Now you should have idea about my issue. Here is a simplified version of markup I'm using (I left out most irrelevant content):
<div class="left">
<div class="box">
// box content
</div>
<div class="box">
// box content
</div>
<div class="box">
// box content
</div>
</div>
<div class="right">
<div class="box">
// box content
</div>
<div class="box">
// box content
</div>
<div class="box">
// box content
</div>
</div>
<div class="clear"></div>
<div class="box">
//
// NOW THIS BOX HAS NO TOP MARGIN
//
</div>
<div class="box">
// box content
</div>
And CSS styles go like this:
.clear {
clear: both;
}
.left {
float: left;
}
.right {
float: right;
}
.box {
overflow: auto;
margin-top: 10px;
}
Obviously I have left out all irreevant styles like borders, background colors and images, font sizes etc. I have kept only important stuff.
Any idea where could be the problem?
See if padding-top: 10px works. It might be that the margin is trying to go from the top of the page.
I think this is an IE8 bug. Relates to a sibling element of a floated left and right div. With or without a clearing div, the final unfloated element loses its top margin in IE8.
We've tested this, and only IE8 gets it wrong:
http://www.inventpartners.com/content/ie8_margin_top_bug
We also came up with 3 solutions.
Try closing your clear div.
<div class="clear"></div>
I don't quite get this approach. You could wrap the <div>s with class right and left in another <div> and apply overflow: hidden, width: 100% to it so that the elements below floated elements will get displayed correctly.
enter code hereTry using a container with a width with overflow:hidden around the floated divs, and remove the cleared div.
<div id="container">
<div class="left">
<div class="box"> // box content </div>
<div class="box"> // box content </div>
<div class="box"> // box content </div>
</div>
<div class="right">
<div class="box"> // box content right </div>
<div class="box"> // box content </div>
<div class="box"> // box content </div>
</div>
</div>
<div class="box"> // // NOW THIS BOX HAS NO TOP MARGIN //</div>
<div class="box"> // box content</div>
And the CSS
#container { width: 100%; overflow: hidden; }
(sorry, I left IE7 on my work machine for testing so I can't verify)
I have similar problems, and the solutions provided by Matt Bradley did not work for me (but thanks for posting it anyway!). I wanted to have margin-top:10px on a h1 element.
The solution I came up with was by adding position:relative , top:10px and margin-top:0px to the h1 element.
I don't have IE8 with me... but did you try adding clear: both to the bottom div and adding a bottom margin to one of the top floats? I'm pretty sure that would achieve the same effect without any extra divs.