The wrapper container css is width:auto; max-height:70%;
I want the divs to maintain their aspect ratio when browser window height changes.
jfiddle: http://jsfiddle.net/7JNuU/
HTML
<div id="feedwrapper">
<!--FULL group-->
<div id="tile">
<div id="fullcell">1</div>
</div>
<!--FULL group-->
<!--4up group-->
<div id="tile">
<div id="solocell">1</div>
<div id="solocell">2</div>
<div id="solocell">3</div>
<div id="solocell">4</div>
</div>
<!--4up group-->
<!--2top group-->
<div id="tile">
<div id="solocell">1</div>
<div id="solocell">2</div>
<div id="cell2xbot">3</div>
</div>
<!--2top group-->
CSS
#feedwrapper{
width:auto;
max-height:70%;
top:80px;
bottom:60px;
margin-bottom:80px;
left:300px;
position:absolute;
background-color:#FFF;
white-space:nowrap;
display:block;
}
#tile{ position:relative; border:none; padding:0px; min-width:640px; height:100%; margin:0px 2px 2px 0px; background-color:#CC6; float:left;}
#fullcell{width:100%; height:100%; background-color:#F99; display:block;}
#solocell{ width:50%; height:50%; background-color:#36C; display:block; float:left;}
#cell2xbot{ width:100%; height:50%; background-color:#C93; display:block; float:left;}
#cell2xtop{ width:100%; height:50%; background-color:#C66; display:block; float:left;}
#cell2yleft{ width:50%; height:100%; background-color:#99C; display:block; float:left;}
#cell2yright{ width:50%; height:100%; background-color:#FC6; display:block; float:right;}
The page I'm working on is: http://www.jordache.com/connect.php
The grid uses squares and rectangles.
50%x50% squares, 100% squares, 50%x/100%y rect, and 100%x/50%y rect.
There must be a simpler way.... grrrrr... help!
Related
I want the red box at the arrow ending position. jsbin
<div id="wrapper">
<div id="blue"></div>
<div id="yellow1">y</div>
<div id="yellow2">y</div>
<div id="red"></div>
</div>
body{width:800px;}
#wrapper{position:relative;}
#blue{
float:left;
height:225px;
width:520px;
background:blue;
}
#yellow1,#yellow2{
position:relative;
width:250px;
height:200px;
margin:10px 0 20px 540px;
background:yellow;}
/*Not working*/
#red{
background:red;
position:absolute;
height:200px;
width:520px;
top:200;
}
top:520 for #red is wrong. You have to write top:230px as top value I think..
You are missing a unit of measurement at the end of top:520; of your #red rule
It should be like top:520px;
Remove top and write margin-top:-195px to #red.
Demo here.
use this code
http://jsbin.com/IxAtOFA/10/edit
#blue{
float:left;
height:225px;
width:520px;
background:blue;
margin:5px;
}
#yellow1,#yellow2{
position:relative;
width:250px;
height:200px;
background:yellow;
float:right;
margin:5px;
}
#red{
background:red;
height:200px;
width:520px;
float:left;
margin:5px;
}
it is solved now, I placed the <div id="red"></div> before the yellow divs, http://jsbin.com/IxAtOFA/12/edit
I can't figure out how to set up the box model for my layout.
The "[container|x]" elements you see are placeholders, which are later replaced by php.
Here is a sketch of how it should look like:
I tried to google it and search here on stack overflow and of course I did find a lot about box models and problems with it, but nothing helped me here.
This is what I already have:
html:
<div class='headerimage'>
[container|1]
</div>
<div class='mainwrapper'>
<div class='femininHead'>
[container|2]
</div>
<div class='lineH1'> </div>
<div class='feminin'>
<div class='femininSub1'>
[container|3]
</div>
<div class='lineV1'> </div>
<div class='femininSub2'>
[container|4]
</div>
<div class='lineV2'> </div>
<div class='femininSub3'>
[container|5]
</div>
</div>
<div style='clear:both;'></div>
<div class='maskulinHead'>
[container|6]
</div>
<div class='lineH2'> </div>
<div='maskulin'>
<div class='maskulinSub1'>
[container|7]
</div>
<div class='lineV3'> </div>
<div class='shopButton'>
[container|8]
</div>
</div>
<div style='clear:both;'></div>
<div class='unisexHead'>
[container|9]
</div>
<div class='lineH3'> </div>
<div class='unisex'>
<div class='unisexSub1'>
[container|10]
</div>
<div class='lineV4'> </div>
<div class='unisexSub2'>
[container|11]
</div>
<div class='lineV5'> </div>
<div class='unisexSub3'>
[container|12]
</div>
</div>
</div>
css:
.headerimage {
position:absolute;
left:0px;right:0px;
background-color:#000000;
height:367px;
}
.mainwrapper{
position:relative;
top:367px;
}
.femininHead {
position:relative;
width:800px;
height:87px;
top:50px;
}
.femininHead .image1_headline{
line-height:30px;
font-size:24px;
position:relative;
}
.feminin {
position:relative;
}
.lineH1{
background-image:url(/img/tempdyn/streifenlinie_horizontal.png);
width:800px;
height:1px;
background-color:#000000;
position:relative;
bottom:2px;
}
.femininSub1 {
position:relative;
width:266px;
height:125px;
float:left;
}
.lineV1{
background-image:url(/img/tempdyn/streifenlinie_vertikal.png);
background-repeat:repeat-y;
background-position:right top;
float:left;
height:128px;
width:1px;
background-color:#000000;
position:relative;
}
.femininSub2 {
position:relative;
width:266px;
height:125px;
float:left;
}
.lineV2{
background-image:url(/img/tempdyn/streifenlinie_vertikal.png);
background-repeat:repeat-y;
background-position:right top;
float:left;
height:128px;
width:1px;
background-color:#000000;
position:relative;
}
.femininSub3{
width:266px;
height:125px;
position:relative;
float:left;
position:relative;
}
.maskulinHead {
position:relative;
width:800px;
height:87px;
top:127px;
}
.maskulinHead .image2_headline{
line-height:36px;
font-size:36px;
right:300px;
}
.lineH2{
background-image:url(/img/tempdyn/streifenlinie_horizontal.png);
width:800px;
height:1px;
background-color:#000000;
position:relative;
top:133px;
}
.maskulin {
position:relative;
}
.maskulinSub1 {
position:relative;
width:266px;
height:125px;
float:left;
position:relative;
}
.lineV3{
background-image:url(/img/tempdyn/streifenlinie_vertikal.png);
background-repeat:repeat-y;
background-position:right top;
float:left;
position:relative;
height:128px;
width:1px;
}
.shopButton {
width:536px;
height:218px;
float:left;
position:relative;
}
.unisexHead{
width:259px;
height:125px;
position:relative;
line-height:36px;
font-size:36px;
}
.unisexHead .image3_headline{
line-height:36px;
font-size:36px;
}
.lineH3{
background-image:url(/img/tempdyn/streifenlinie_horizontal.png);
width:800px;
height:1px;
background-color:#000000;
position:relative;
top:594px;
}
.unisex {
position:relative;
}
.unisexSub1
position:relative;
width:266px;
height:125px;
float:left;
}
.lineV4{
background-image:url(/img/tempdyn/streifenlinie_vertikal.png);
background-repeat:repeat-y;
background-position:right top;
float:left;
background-color:#000000;
position:relative;
height:128px;
width:1px;
}
.unisexSub2 {
position:relative;
width:266px;
height:125px;
float:left;
}
.lineV5{
background-image:url(/img/tempdyn/streifenlinie_vertikal.png);
background-repeat:repeat-y;
background-position:right top;
float:left;
background-color:#000000;
position:relative;
height:128px;
width:1px;
}
.unisexSub3{
width:266px;
height:125px;
position:relative;
float:left;
}
Thanks in advance :)
can't see why box-model can help you with this. maybe you are looking for FlexBox! Or go classic and use display:inline-block for the nested boxes(3,4,5,7,8,10,11,12) and all others just row divs.
But don't use floats any more!
Check out this simplified solution on JSBin.
The basic idea is to wrap all the items except the 1st box in a containing wrapper .wrap. A horizontal margin of auto along with a fixed width will center it in the page. Within that, you have your side-by-side boxes float left and give them fixed widths. The div below them needs to clear the float.
Hope the example is helpful.
How do you place child in front of a parents sibling with higher z-index?
I want the pink box to apear in front of the green.
http://jsfiddle.net/Tim86/YRTxt/
<style>
#wrapper{
position:relative;
width:400px;
}
#red, #green{
height:200px;
width:400px;
}
#red{
background-color:red;
position:relative;
z-index:10;
}
#pink{
background-color:pink;
height:250px;
width:150px;
top:50px;
right:20px;
position:absolute;
z-index:40;
}
#green{
opacity:0.8;
background-color:green;
position:relative;
z-index:20;
top:-50px;
}
</style>
<div id="wrapper">
<div id="red">
<div id="pink">
</div>
</div>
<div id="green">
</div>
</div>
You need to remove position:relative; from #red and it's done.
Demo
I'd like to make something that looks like the below image using CSS:
I'm at a total loss on how to do that. Might someone help?
This can be done using two elements or one element and a pseudo-element:
HTML:
<div></div>
CSS:
div { position:relative; background-color:#333; padding:20px;
margin:20px; float:left; }
div:before { content:""; display:block; padding:5px; background-color:#f60;
border:2px solid white; position: absolute; top:-2px;
right:-2px;}
http://jsfiddle.net/Vv6Eb/
Update:
With border-top-right-radius:
http://jsfiddle.net/Vv6Eb/1/
Or, border-bottom-left-radius:
http://jsfiddle.net/Vv6Eb/4/
<div id="page">
<div id="up">
</div>
<div id="logo">
<div id="logobody"></div>
</div>
<div id="down">
</div>
</div>
#page{
margin:30px auto;
width:500px;
height:auto;
border-radius:10px;
border:2px red thin;
background:white;
overflow:hidden;
}
#logo{
float:right;
width:100px;
height:70px;
border-radius:10px;
background:white;
margin-top:-70px;
margin-right:10px;
}
#up{
width:80%;
height:60px;
border-radius-top:10px;
background:gray;
}
#down{
margin-top:-0px;
margin-right:-10px;
width:100%;
height:60px;
border-radius: 0px 10px 10px 10px;
background:gray;
}
#logobody{
border:2px blue solid;
margin :auto;
width:85px;
height:50px;
margin-top:10px;
margin-right:0px;
border-radius:7px;
}
jsFiddle
Use float..http://www.w3schools.com/css/css_float.asp
<div style="background-color:#000; height:500px; width:500px; margin-bottom:10px;">
<div style="background-color:#FFF; float:right; height:100px; width:100px; margin-right:10px; margin-top:10px;"></div>
</div>
<div style="background-color:#000; height:500px; width:500px; position:relative;">
<div style="background-color:#FFF; position:absolute; right:0px; height:100px; width:100px; margin-right:10px; margin-top:10px;"></div>
</div>
Inline styles is not advisable so might wanna write the styles in your stylesheet file. Using float makes the texts wraps the div tag. The seconds code stacks
I've a container, where i have some divs : header, content, footer (as a standart application).
this is the structure :
<body>
<div>
<div id="ROOT" >
<div id="ROOT_0" >
Header
</div>
<div id="ROOT_1" >
Content
</div>
<div id="ROOT_2" >
Footer
</div>
</div>
</div>
</body>
The actual CSS :
html {height:101%;}
body {background:#999999;}
#ROOT{ background-color:#333333; width:980px; margin-left:auto; margin-right:auto; overflow:auto;}
#ROOT_0{background-color:#FF9933; width:970px; text-align:center; float:left; margin-top:5px; margin-left:5px; margin-right:5px; margin-bottom:5px;}
#ROOT_1{width:980px; text-align:center; float:left; background-image:url(../img/sfondofc.jpg);}
#ROOT_2{background-color:#FF9933; width:970px; padding-top:5px; padding-bottom:5px; text-align:center; float:left; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px; font-weight:bold; font-size:13px;}
background-color:#FF9933; width:970px; padding-top:5px; padding-bottom:5px; text-align:center; float:left; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px; font-weight:bold; font-size:13px;
unfortunatly, on IE (6) i can't see the margin-bottom:5px; in the end, where i have the footer. Which propriety i need to change? Cheers
why did you set the height property of html to 101 percent ?