Why in the following code there is no bottom padding in Internet Explorer 8 ?
HTML:
<div id="wrapper">
<div class="a">Hello</div>
<div class="a">Stack</div>
<div class="a">Overflow</div>
</div>
CSS:
#wrapper {
border: 1px solid red;
padding: 10px;
height: 30px;
overflow: auto;
}
.a {
border: 1px solid black;
}
Any workarounds for browser compatibility ?
browser interpretation of the specs?
A value of 'scroll' would tell UAs
that support a visible scrolling
mechanism to display one so that users
could access the clipped content.
Taken literally that means they, the browsers, can please themselves and they only have to provide access to the content not the padding or borders ;)
a compatible workaround:
#scroller {
border: 1px solid red;
height: 50px;
overflow: auto;
}
.wrap {padding: 10px;}
.a {
border: 1px solid black;
}
HTML:
<div id="scroller">
<div class="wrap">
<div class="a">Hello</div>
<div class="a">Stack</div>
<div class="a">Overflow</div>
</div>
</div>
How about going dirty? (Heck, I'm a programmer, not a designer lol).
<style type="text/css">
#wrapper {
border: 1px solid red;
padding: 10px;
height: 30px;
overflow: auto;
}
.a {
border: 1px solid black;
}
.b {
display:none;
}
</style>
<!--[if IE 8]>
<style type="text/css">
.b {
display:block;
height: 10px;
}
</style>
<![endif]-->
And:
<div id="wrapper">
<div class="a">Hello</div>
<div class="a">Stack</div>
<div class="a">Overflow</div>
<div class="b"></div>
</div>
:D
Read this post i think it will be helpful it did the trick for me
add display: block; to #wrapper {} - I had exactly the same issue, with this added padding-bottom started to work properly under IE8 and other browsers was not affected (keep the proper output)
You can add a pseudo-element «after» only for IE8:
<!--[if IE 8]>
<style type="text/css">
#wrapper:after {
content: '';
display: block;
height: 10px;
}
</style>
<![endif]-->
Related
This works fine in chrome but IE doesn't like it and breaks the content-main div's.
Checked for word-wrap: break-word as noted here white-space: nowrap is not working in IE in a horizontally scrolling box but I don't have that anywhere.
Here's a fiddle http://jsfiddle.net/02hgaahe/ although the fiddle in IE displays correctly.... odd.
Here's my code.
HTML-
/*
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
*/
/*
Created on : Jan 7, 2015, 2:31:39 PM
*/
body {
font-family:arial,helvetica,sans-serif;
font-size:12px;
}
#wrapper {
margin:0px auto;
border:1px solid #bbb;
padding:10px;
height: 90%;
}
#header {
border:1px solid #bbb;
height:80px;
padding:10px;
}
#header > #content-main{
width:200px;
height:80px;
border: 1px solid #bbb;
}
.content {
margin-top:10px;
padding-bottom:10px;
white-space: nowrap;
overflow-x: visible;
overflow-y: hidden;
height:320px;
}
.content div {
border:1px solid #bbb;
}
.content-main {
display: inline-block;
width:500px;
height:300px;
}
#footer {
margin-top:10px;
padding:10px;
border:1px solid #bbb;
}
#bottom {
clear:both;
text-align:right;
}
<div id="wrapper">
<div id="header">Header</div>
<div class="content">
<div class="content-main">Left</div>
<div class="content-main">main</div>
<div class="content-main">right</div>
<div class="content-main">right</div>
<div class="content-main">right</div>
<div class="content-main">right</div>
<div class="content-main">right</div>
<div class="content-main">right</div>
<div class="content-main">right</div>
</div>
<div id="footer"></div>
<div id="bottom"></div>
</div>
Edit: Removed duplicate ID's and incorrect comment.
It is still displaying incorrectly though.
Edit: I think the issue was with Internet Explorer's compatibility settings for intranet sites, I didn't know that IE defaulted all intranet sites to compatibility mode (basically IE7).
Time for a shot in the dark!
Did you remember <!DOCTYPE html> at the start of your HTML file? Without it, older IE versions will default to Quirks Mode, which may not behave properly when it comes to CSS.
I believe the issue here is that you're using repeating id's.
If you want to 'duplicate' the effects of one div onto another, try using a class instead.
Using classes makes the 'class' reusable, unlike using 'id's, which should be unique and not repeated. Duplicating ID's cause all sorts of funny bugs/glitches.
Something like:
body {
font-family: arial, helvetica, sans-serif;
font-size: 12px;
}
#wrapper {
margin: 0px auto;
border: 1px solid #bbb;
padding: 10px;
height: 90%;
}
#header {
border: 1px solid #bbb;
height: 80px;
padding: 10px;
}
#header > #content-main {
width: 200px;
height: 80px;
border: 1px solid #bbb;
}
#content {
margin-top: 10px;
padding-bottom: 10px;
white-space: nowrap;
overflow-x: visible;
overflow-y: hidden;
height: 320px;
}
#content div {
/*padding:10px;*/
border: 1px solid #bbb;
}
.content-main {
display: inline-block;
width: 500px;
height: 300px;
}
#footer {
margin-top: 10px;
padding: 10px;
border: 1px solid #bbb;
}
#bottom {
clear: both;
text-align: right;
}
<div id="wrapper">
<div id="header">Header</div>
<div id="content">
<div class="content-main">Left</div>
<div class="content-main">main</div>
<div class="content-main">right</div>
<div class="content-main">right</div>
<div class="content-main">right</div>
<div class="content-main">right</div>
<div class="content-main">right</div>
<div class="content-main">right</div>
<div class="content-main">right</div>
</div>
<div id="footer"></div>
<div id="bottom"></div>
</div>
As a side note, as #James said, comments in css look like /*comment*/ and not //comment
I got a problem with HTML, the problem is footer overlay in main like this image
I want to create a left sidebar in main page, a header at a top, and a footer. Besides I used RenderBody() for main in my HTML:
<div class="left">
LEFT
</div>
<div id="main">
#RenderBody()
</div>
<div id="footer">
built with <a target="_blank" href="http://asp.net/mvc"> ASP.NET MVC 4</a>
<button style="margin-left: 25px; float:left">Slide Toggle</button>
</div>
Here my CSS:
#main
{
position: absolute;
left:178px; top:92px; right:0; bottom:0;
}
#left {
position:absolute;
float:left;
width: 178px;
min-height: 400px;
}
#footer
{
clear: both;
padding: 10px;
text-align: right;
border-top: 1px dotted #8A8575;
border-bottom: 1px dotted #8A8575;
clear: both;
font-family: Constantia, Georgia, serif;
}
Any suggestions how to fix that problem.
Firstly, it should be div id="left" in your html since in your css "#left" not ".left".
Secondly, what lee8oi said is true.You can try his method.
Thirdly, you also can applying this method jsfiddle by adding a new div (set display:inline-block) to wrap #left and #main by set "#left" as float:left and "#main" as float:right.
.wrapper
{
display:inline-block;
}
#main
{
background-color:yellow;
float:right;
}
#left
{
float:left;
width: 178px;
background-color:blue;
}
Addition: I'm just putting background-color to make clearer to you where the div is. Good Luck!!.
Well one problem is that you can't 'position: absolute' and 'float: left' in the same element. They both position elements in different ways.
The answer to your question, I believe, would be CSS's 'display: inline-block'. Normally div's are not allowed to render side-by-side. Instead maybe you should try something like this:
<!doctype html>
<html lang="en">
<head>
<title><!-- Insert your title here --></title>
<style>
div.inline
{
color: red;
display: inline-block
}
#main
{
border: 1px solid blue;
width: 100%;
height: auto;
}
#head {
height: 100px;
width: 100%;
border: 1px solid green;
}
#left {
width: 15%;
min-height: 400px;
border: 1px solid red;
}
#body {
width: 84%;
}
#footer
{
padding: 10px;
text-align: right;
border-top: 1px dotted #8A8575;
border-bottom: 1px dotted #8A8575;
font-family: Constantia, Georgia, serif;
}
</style>
</head>
<body>
<div id="main">
<div id="head">
The header
</div>
<div id="left" class="left inline">
LEFT
</div>
<div id="body" class="inline">
#RenderBody()
</div>
<div id="footer">
built with <a target="_blank" href="http://asp.net/mvc"> ASP.NET MVC 4</a>
<button style="margin-left: 25px; float:left">Slide Toggle</button>
</div>
</div>
</body>
</html>
I have 3 divs inside a main div as marked up in the HTML /CSS code below, when the page renders, the second div is twice as large as the first and last. When the page renders, because the second div is twice the size of the first and last, this causes the last div to display below the second, leaving a gap inbetween. What I want is that the third div occupies that gap that:
<html>
<head>
<title>Liquid Divs</title>
<style>
#splash {
width: 600px;
margin: 1px;
border: solid 1px #ccc;
}
.box {
width: 196px;
height: 196px;
margin: 1px;
border: solid 1px #ccc;
float: left;
}
.box2 {
width: 392px;
height: 392px;
margin: 1px;
border: solid 1px #ccc;
float: left;
}
.clear-fix {
clear: both;
}
</style>
</head>
<body>
<div id="splash">
<div class="box">
</div>
<div class="box2">
</div>
<div class="box">
</div>
<div class="clear-fix">
</div>
</div>
</body>
</html>
Can this be done with CSS or does anyone know a method to accomplish this with javascript? It will be helpful to figure this out.
Switch up your box2 to float right
.box2 {
width: 392px;
height: 392px;
margin: 1px;
border: solid 1px #ccc;
float: right;
}
Tested and it works placing the 3rd box beneath the first
if you plan on including more elements in #splash you are after the jQuery plugin masonry
here is a soltion demo for the extension problem
http://jsfiddle.net/kxMYS/
$( function() {
$('#splash').masonry({
itemSelector: 'div'
});
});
however
if you only want a solution to you're exact given problem
just change your css for .box2 to float:left;
http://jsfiddle.net/kxMYS/1/
Wrap 1st and 3rd boxes in left-container and the big box in right-container
Try this instead: http://jsfiddle.net/wcQ3L/1/
<html>
<head>
<title>Liquid Divs</title>
<style>
#splash {
width: 600px;
margin: 1px;
border: solid 1px #ccc;
}
#left-container{
float: left;
}
.box {
width: 196px;
height: 196px;
margin: 1px;
border: solid 1px #ccc;
}
.box2 {
width: 392px;
height: 392px;
margin: 1px;
border: solid 1px #ccc;
float: left;
}
.clear-fix {
clear: both;
}
</style>
</head>
<body>
<div id="splash">
<div id="left-container">
<div class="box">
</div>
<div class="box">
</div>
</div>
<div id="right-container">
<div class="box2">
</div>
</div>
<div class="clear-fix">
</div>
</div>
</body>
</html>
I've been fiddling with this the entire day and the closest I got is the following layout that works in Chrome (but not in Firefox).
Is it possible to do without the tables (and without js)?
Is it possible to make it cross-browser(tables or not but no js)?
To see the desired behavior, try changing the height of the window/display box.
Main points are:
1. The layout is always at least the size of the window, but can expand past it if the content on the left pushes it.
2. The scrollable area on the right always takes up the whole interior space, but doesn't expand it, meaning the height of the interior is determined by the left content (or size of window, whichever is larger).
Here is a JSFiddle link: http://jsfiddle.net/BNmJM/
And the code:
<!doctype html>
<html>
<head>
<style type="text/css">
*{
margin: 0;
padding: 0;
border: 0;
}
html, body {
height: 100%;
}
td{
vertical-align:top;
}
#wrapper{
border-collapse: collapse;
border-spacing: 0;
width:500px;
margin:0 auto;
border-left:2px dashed black;
border-right:2px dashed black;
height: 100%;
}
</style>
</head>
<body>
<table id="wrapper">
<tr><td colspan=2 style="height:20px;">
<div style="border-bottom:2px dashed black;height:20px;text-align:center;">header</div>
</td></tr>
<tr>
<td>
<div id="contentLeft" style="height:300px; width:100px;border:6px dashed green;"></div>
</td>
<td style="width:100px;border-left:2px dashed black">
<div style="height:100%;width:100px;overflow-y:scroll;">
<div id="contentRight" style="height:500px; width:60px;border:6px dashed red;"></div>
</div>
</td>
</tr>
<tr><td colspan=2 style="height:20px;">
<div style="border-top:2px dashed black;height:20px;text-align:center;">footer</div>
</td></tr>
</table>
</body>
</html>
This actually seems to work in both the browsers (Chrome and Firefox). You can start from here and tweak accordingly.
<!doctype html>
<html>
<head>
<style type="text/css">
*{
margin: 0;
padding: 0;
border: 0;
}
html, body {
height: 100%;
}
td{
vertical-align:top;
}
#wrapper{
position: absolute;
top 0px;
bottom: 0px;
left: 0px;
right: 0px;
border-collapse: collapse;
border-spacing: 0;
width:500px;
margin:0 auto;
border-left:2px dashed black;
border-right:2px dashed black;
height: 100%;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="left-menu" style="width: 100px; height: 100px; border: 1px solid black; float: left;"></div>
<div id="middle-content" style="width: 100px; height: 100px; border: 1px solid black; float: left;"></div>
<div id="right-scroll" style="width: 100px; height: 100%; overflow-y: scroll; border: 1px solid black; float: left;"></div>
<div style="clear: both;"> </div>
</div>
</body>
</html>
http://jsfiddle.net/cSTzA/5/
Here's a start that works in Chrome and Firefox. It shows a layout that is always 100% with a fixed header and footer, and a scrolling right-hand pane.
Unfortunately it does not account for the left side growing but it should give you some ideas on how to proceed. It is possible but the complete solution isn't coming to me at the moment.
Here are several tricks that I use which may assist you in finding the complete solution:
negative margins
box-sizing
a mix of absolute and relative positioning
a mix of display styles (inline-block can be handy)
Finally figured it out using some box-sizing hacks, thanks to #Tim Medora for the help!
Unfortunately though, box-sizing doesn't work in IE7.
Here is the JSFiddle if anyone needs it: http://jsfiddle.net/vfMNw/
And the code:
<!doctype html>
<html><head>
<style media="screen" type="text/css">
html,
body {
margin:0;
padding:0;
height:100%;
}
#container {
min-height:100%;
position:relative;
}
#header {
position:absolute;
z-index:2;
background:#ff0;
padding:10px;
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box;
height:70px;
width:100%;
}
#body {
padding:10px;
padding-bottom:60px; /* Height of the footer */
}
#body1 {
height: 100%;
background-color: #aaa;
position: absolute;
border-top: 70px solid black;
top: 0;
border-bottom: 50px solid black;
overflow-y: scroll;
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box;
right: 0;
width:100px;
}
#footer {
position:absolute;
bottom:0;
width:100%;
height:50px; /* Height of the footer */
background:#6cf;
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box;
}
/* other non-essential CSS */
#header p,
#header h1 {
margin:0;
padding:10px 0 0 10px;
}
#footer p {
margin:0;
padding:10px;
}
</style>
<!--[if lt IE 7]>
<style media="screen" type="text/css">
#container {
height:100%;
}
</style>
<![endif]-->
</head>
<body>
<div id="container">
<div id="header">
<h1>How to keep footers at the bottom of the page (CSS demo)</h1>
</div>
<div id="body">h<br>h<br>h<br>h<br>h<br>h<br>h<br>h<br>h<br>h<br>h<br>h<br>h<br></div>
<div id="body1">
h<br>h<br>h<br>h<br>h<br>h<br>h<br>h<br>h<br>h<br>h<br>h<br>h<br>h<br>h<br>h<br>h<br>h<br>
</div>
<div id="footer">
<p><strong>Footer</strong> (always at the bottom). View more website layouts and web design articles.</p>
</div>
</div>
</body>
</html>
I'd like to have a [Fixed][Liquid][Fixed] cross-browser compatible layout.
HTML:
body
div#col-1
div#col-2
div#col-3
CSS:
#col-1 {
width:150px;
float:left;
}
#col-2 {
width:100%;
padding:0 150x;
}
#col-3 {
positon:absolute:
right:0;
width:150px;
}
Would this work/better way to do it?
This is pretty simple.
here is the code
<html>
<head>
<style type="text/css">
#left {
float: left;
width: 150px;
border: 1px solid black;
background-color: #999;
height: 50px;
}
#right {
float: right;
width: 150px;
border: 1px solid black;
background-color: #999;
height: 50px;
}
#center {
/* margin with 10px margin between the blocks*/
margin: 0 160px;
border: 1px solid black;
height: 50px;
}
</style>
</head>
<body>
<div id="left">Text</div>
<div id="right">Text</div>
<div id="center">Text</div>
</body>
</html>
I'm using floats instead of position absolute. The advantage of using floats above absolute positioning is that you can put a nother div beneath it, lets say the footer. And just give it a clear: both and it will automatically display at the bottom of the page.
here is an example with a footer
<html>
<head>
<style type="text/css">
#left {
float: left;
width: 150px;
border: 1px solid black;
background-color: #999;
height: 50px;
}
#right {
float: right;
width: 150px;
border: 1px solid black;
background-color: #999;
height: 50px;
}
#center {
/* margin with 10px margin between the blocks*/
margin: 0 160px;
border: 1px solid black;
height: 50px;
}
#footer {
clear: both;
margin-top: 10px;
border: 1px solid black;
}
</style>
</head>
<body>
<div id="left">Text</div>
<div id="right">Text</div>
<div id="center">Text</div>
<div id="footer">footer</div>
</body>
</html>
Voila! You've got your liquid layout.
check this out:
http://siteroller.net/articles/3-column-no-tables-no-floats
But no,I don't think that would work. There are plenty of links in said article though to address your issue.
And if there is any interest, I will extend what is written there.
Okay, got it: http://www.dynamicdrive.com/style/layouts/item/css-liquid-layout-31-fixed-fluid-fixed/
I like Robert's answer. I would also add a wrapper around the left, right, center and footer. Here, I set the id to "page":
<body>
<div id="page">
<div id="left">Text</div>
<div id="right">Text</div>
<div id="center">Text</div>
<div id="footer">footer</div>
</div>
</body>
Then, you can also add the style for the "page":
#page {
min-width: 600px;
}
This way, if the user shrinks their browser down to a very small size, the content still looks good.