CSS - Can't send div to the right? - css

I'm trying to send a div block to the right side of my page with a float:right; but it doesn't work.
HTML :
<div id="footer_div">
<footer>
<div class="copyrights">
<a href="contact.html" style="
color:#8C8C8C;
font-weight:bold;
text-decoration:none;
font-size:xx-small;
"><center>Site © 2013</center></a>
</div>
<div class="footer_links">
<a href="cgu.html" style="
color:#FFF;
font-weight:bold;
text-decoration:none;
font-size:xx-small;
">Conditions d'utilisation</a>
<a href="about.html" style="
color:#FFF;
font-weight:bold;
text-decoration:none;
font-size:xx-small;
">A propos</a>
<a href="help.html" style="
color:#FFF;
font-weight:bold;
text-decoration:none;
font-size:xx-small;
">Aide</a>
<a href="contact.html" style="
color:#FFF;
font-weight:bold;
text-decoration:none;
font-size:xx-small;
">Contact</a>
</div>
</footer>
</div>
CSS :
footer
{
position:fixed;
bottom:0;
height:45px;
width:100%;
background:url(Templates/footer1.png) repeat-x bottom;
}
.copyrights
{
float:left;
position:fixed;
bottom:17.5px;
text-decoration:none;
margin-left:8px;
}
.footer_links
{
float:right;
height:20px;
width:240px;
position:fixed;
bottom:17.5px;
text-decoration:none;
border:0px solid;
}
Any idea how I can solve that ?
I want the .footer_links to go to the right side of my page.
Thanks !
Chris.

Take off the position fixed you have specified on the .footer-links class.
See this jsFiddle example.

http://jsfiddle.net/wCMqY/6/
footer
{
position:fixed;
bottom:0;
height:45px;
width:100%;
background:red;
}
.copyrights
{
float:left;
bottom:17.5px;
text-decoration:none;
margin-left:8px;
}
.footer_links
{
float:right;
height:20px;
width:240px;
text-decoration:none;
border:0px solid;
background:green;
}
.clear {
clear:both;
}
It's the position fixed that's causing you problems

Related

1 image and two elements floating right next to it

I am trying to have 1 image and two elements floating right next to it (and the two elements on two separate lines). I tried working with display:inline-block so that each of the two elements comes on a separate line, but no luck. Also, the "brand" should be on top of the "model", thus first Mercedes and second W126. Is it possible to achieve this?
Fiddle here... Fiddle
HTML:
<div class="car"><img alt="" src=
"http://placehold.it/50x50&text=CAR"></div>
<div class="brand">
Mercedes
</div>
<div class="model">
W126
</div>
CSS:
.car img {
max-width:100%;
max-height:100%;
margin:0;
display:block;
}
.brand {
font-size:16px;
color:#333333;
font-family:'Droid Serif';
font-weight:bold;
padding-left:10px;
padding-bottom:0px;
padding-top:5px;
float:left;
margin-left:2px;
margin-right:2px;
margin-top:2px;
display:inline-block;
}
.model {
font-size:12px;
color:#5A5A5A;
font-family:'Droid Serif';
font-style:normal;
margin-left:2px;
margin-right:2px;
margin-bottom:2px;
padding-left:10px;
float:left;
display:inline-block;
}
It's easy if you change the HTML & CSS a bit:
.car {
display:inline-block;
}
.car img {
max-width:100%;
max-height:100%;
margin:0;
display:inline-block;
vertical-align:middle;
}
.car .makeAndModel {
margin:0 0 0 5px;
font-family:'Droid Serif';
display:inline-block;
vertical-align:middle;
}
.brand {
font-size:16px;
color:#333333;
font-weight:bold;
display:block;
}
.model {
font-size:12px;
color:#5A5A5A;
font-style:normal;
display:block;
}
<div class="car">
<img alt="" src="http://placehold.it/50x50&text=CAR" />
<div class="makeAndModel">
<div class="brand">
Mercedes
</div>
<div class="model">
W126
</div>
</div>
</div>
You can use some floats instead:
.car img {
max-width:100%;
max-height:100%;
margin:0;
float:left;
}
.brand {
font-size:16px;
color:#333333;
font-family:'Droid Serif';
font-weight:bold;
padding-left:10px;
padding-bottom:0px;
padding-top:5px;
margin-left:52px;
margin-right:2px;
margin-top:2px;
}
.model {
font-size:12px;
color:#5A5A5A;
font-family:'Droid Serif';
font-style:normal;
margin-left:2px;
margin-right:2px;
margin-bottom:2px;
padding-left:10px;
float:left;
}
<div class="car">
<img alt="" src="http://placehold.it/50x50&text=CAR">
</div>
<div class="brand">Mercedes</div>
<div class="model">W126</div>
Note that .brand has no float which allows the W126 to be pushed to the line below it, and the margin has been increased to space it properly.

How to center a 3 column Css Div Site?

My site has a 100% width header & footer, and 3 columns. The columns need to all be fixed width, but in the center of the page.
HTML
<div id="Table_01">
<div id="Header"></div>
<span id="LeftCol">Left Col </span>
<span id="MidCol">Middle </span>
<span id="RightCol">Right Col </span>
<div id="Footer">Footer</div>
</div>
CSS
#Table_01 {
position:absolute;
left:0px;
top:0px;
width:100%;
}
#Header {
position:absolute;
left:0px;
top:0px;
width:100%;
height:42px;
background-image: url("images/Header.gif");
}
#LeftCol {
position:absolute;
left:0px;
top:42px;
width:300px;
height:422px;
text-align:center;
border:2px solid;
}
#MidCol {
position:absolute;
left:300px;
top:42px;
width:550px;
height:422px;
text-align:center;
border:2px solid;
}
#RightCol {
position:absolute;
left:850px;
top:42px;
width:300px;
height:422px;
text-align:center;
border:2px solid;
}
#Footer {
position:absolute;
left:0px;
top:464px;
width:1000px;
height:1536px;
}
JSFIDDLE
What you need is a mix of position:relative and margin:0 auto applied to a container.
Add a container div:
.container {
width:1150px;
margin:0 auto;
position:relative;
}
See updated JSFIDDLE

trouble with box model

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 to make rounded corner cut-out using CSS?

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

CSS - IE don't get the margin-bottom from the last div

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 ?

Resources