CSS float right and vertically center an element - html

I am trying to push the sign out button to the right but have it aligned vertically in the centre.
Here is an example:
#sessionManageWrapper {
max-width: 45%;
}
#sessionManageWrapper .sessionBox:not(:last-child) {
margin-bottom: 5px;
}
.sessionBox {
background-color: #444343;
padding: 4px;
border-radius: 3px;
border: 2px solid grey;
vertical-align: middle;
}
.sessionBox img {
vertical-align: middle;
height: 32px;
width: 32px;
}
.logoutSessWrapper {
float: right;
line-height: 15px;
}
.sessionBox p {
margin: 0;
vertical-align: middle;
display: inline-block;
}
.sessionBox p:not(:last-child) {
margin-right: 10px;
}
.sessionSeparator {
background-color: grey;
width: 1px;
height: 24px;
display: inline-block;
vertical-align: middle;
}
.activeCircle {
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
border: 1px solid #ccc;
width: 8px;
height: 8px;
display: inline-block;
vertical-align: middle;
}
.sessionActiveGreen {
background-color: green;
}
.redButton {
-moz-box-shadow: inset 0px 1px 0px 0px #cf866c;
-webkit-box-shadow: inset 0px 1px 0px 0px #cf866c;
box-shadow: inset 0px 1px 0px 0px #cf866c;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #d0451b), color-stop(1, #bc3315));
background: -moz-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background: -webkit-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background: -o-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background: -ms-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background: linear-gradient(to bottom, #d0451b 5%, #bc3315 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#d0451b', endColorstr='#bc3315', GradientType=0);
background-color: #d0451b;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
border: 1px solid #942911;
display: inline-block;
cursor: pointer;
color: #ffffff;
font-size: 13px;
padding: 6px 19px;
text-decoration: none;
text-shadow: 0px 1px 0px #854629;
}
.redButton:hover {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #bc3315), color-stop(1, #d0451b));
background: -moz-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background: -webkit-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background: -o-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background: -ms-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background: linear-gradient(to bottom, #bc3315 5%, #d0451b 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#bc3315', endColorstr='#d0451b', GradientType=0);
background-color: #bc3315;
}
.redButton:active {
position: relative;
top: 1px;
}
<div id="sessionManageWrapper">
<div class="sessionBox activeSession">
<div class="activeCircle sessionActiveGreen" title="Online, active"></div>
<img src="http://i.imgur.com/k0h3WPJ.png">
<div class="sessionSeparator"> </div>
<p>#currentSessLocation</p>
<p>#currentSessDevice</p>
<p>#currentSessIP</p>
<div class="logoutSessWrapper">Sign Out</div>
</div>
</div>
I know vertically align does not work with float but I can't seem to find a way to get that sign out button centre like the rest of the elements in the session box div.

Just use absolute positioning. It's a simple method to vertically center and right-align the button.
.sessionBox {
background-color: #444343;
padding: 4px;
border-radius: 3px;
border: 2px solid grey;
vertical-align: middle;
position: relative; /* NEW; set nearest positioned ancestor for abspos child */
}
.logoutSessWrapper {
/* float: right; */
line-height: 15px;
position: absolute; /* NEW */
right: 5px; /* NEW */
top: 50%; /* NEW */
transform: translateY(-50%); /* NEW */
}
#sessionManageWrapper {
max-width: 45%;
}
#sessionManageWrapper .sessionBox:not(:last-child) {
margin-bottom: 5px;
}
.sessionBox {
background-color: #444343;
padding: 4px;
border-radius: 3px;
border: 2px solid grey;
vertical-align: middle;
position: relative; /* NEW; set nearest positioned ancestor for abspos child */
}
.sessionBox img {
vertical-align: middle;
height: 32px;
width: 32px;
}
.logoutSessWrapper {
/* float: right; */
line-height: 15px;
position: absolute; /* NEW */
right: 5px; /* NEW */
top: 50%; /* NEW */
transform: translateY(-50%); /* NEW */
}
.sessionBox p {
margin: 0;
vertical-align: middle;
display: inline-block;
}
.sessionBox p:not(:last-child) {
margin-right: 10px;
}
.sessionSeparator {
background-color: grey;
width: 1px;
height: 24px;
display: inline-block;
vertical-align: middle;
}
.activeCircle {
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
border: 1px solid #ccc;
width: 8px;
height: 8px;
display: inline-block;
vertical-align: middle;
}
.sessionActiveGreen {
background-color: green;
}
.redButton {
-moz-box-shadow: inset 0px 1px 0px 0px #cf866c;
-webkit-box-shadow: inset 0px 1px 0px 0px #cf866c;
box-shadow: inset 0px 1px 0px 0px #cf866c;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #d0451b), color-stop(1, #bc3315));
background: -moz-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background: -webkit-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background: -o-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background: -ms-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background: linear-gradient(to bottom, #d0451b 5%, #bc3315 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#d0451b', endColorstr='#bc3315', GradientType=0);
background-color: #d0451b;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
border: 1px solid #942911;
display: inline-block;
cursor: pointer;
color: #ffffff;
font-size: 13px;
padding: 6px 19px;
text-decoration: none;
text-shadow: 0px 1px 0px #854629;
}
.redButton:hover {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #bc3315), color-stop(1, #d0451b));
background: -moz-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background: -webkit-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background: -o-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background: -ms-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background: linear-gradient(to bottom, #bc3315 5%, #d0451b 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#bc3315', endColorstr='#d0451b', GradientType=0);
background-color: #bc3315;
}
.redButton:active {
position: relative;
top: 1px;
}
<div id="sessionManageWrapper">
<div class="sessionBox activeSession">
<div class="activeCircle sessionActiveGreen" title="Online, active"></div>
<img src="http://i.imgur.com/k0h3WPJ.png">
<div class="sessionSeparator"> </div>
<p>#currentSessLocation</p>
<p>#currentSessDevice</p>
<p>#currentSessIP</p>
<div class="logoutSessWrapper">Sign Out</div>
</div>
</div>
jsFiddle
For a complete explanation of how this centering method works see:
Element will not stay centered, especially when re-sizing screen

As far as i understood what you are trying to achieve, i edited your code, and added few divs and few css classes, and it works perfectly, here it is:
HTML
<div id="sessionManageWrapper">
<div class="sessionBox activeSession">
<div class="activeCircle sessionActiveGreen" title="Online, active"></div>
<img src="http://i.imgur.com/k0h3WPJ.png">
<div class="sessionSeparator"> </div>
<p>#currentSessLocation</p>
<p>#currentSessDevice</p>
<p>#currentSessIP</p>
<!-- additional Markup -->
<div class="wrap">
<div class="dt">
<div class="dc">
<div class="logoutSessWrapper">Sign Out</div>
</div>
</div>
</div>
</div> <!-- wrap ends -->
</div>
ADDITIONAL CSS
#sessionManageWrapper {
max-width: 45%;
position: relative;
}
.dt {
display: table;
width: 100%;
height: 100%;
}
.wrap {
position: absolute;
width: 100%;
height: 100%;
top: 0px;
left: 0px;
}
.dc {
display: table-cell;
vertical-align: middle;
}
Here is a fiddle of it

Related

What is wrong with my layout? Fixed Header with iframe

I am trying to make a iframe for website demos so I want to add a fixed header. Why does my right Buy Now Button will keep getting lower then it should? I have tried a few things but I am not a coder.
Here is my code:
#headerfix {
height: 60px;
background-color:#000;
border-bottom: 2px solid gold;
z-index: 99999;
position: fixed;
width: 100%;
}
.button {
border: 2px solid gold;
background: #ff9900;
background: -webkit-gradient(linear, left top, left bottom, from(#ffff00), to(#ff9900));
background: -webkit-linear-gradient(top, #ffff00, #ff9900);
background: -moz-linear-gradient(top, #ffff00, #ff9900);
background: -ms-linear-gradient(top, #ffff00, #ff9900);
background: -o-linear-gradient(top, #ffff00, #ff9900);
background-image: -ms-linear-gradient(top, #ffff00 0%, #ff9900 100%);
padding: 7.5px 15px;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
-webkit-box-shadow: rgba(255,255,255,0.4) 0 1px 0, inset rgba(255,255,255,0.4) 0 1px 0;
-moz-box-shadow: rgba(255,255,255,0.4) 0 1px 0, inset rgba(255,255,255,0.4) 0 1px 0;
box-shadow: rgba(255,255,255,0.4) 0 1px 0, inset rgba(255,255,255,0.4) 0 1px 0;
text-shadow: #303030 0 1px 0;
color: #000000;
font-size: 18px;
font-family: helvetica, serif;
text-decoration: none;
vertical-align: middle;
}
.button:hover {
border: 2px solid #d9ff00;
text-shadow: #1e4158 0 1px 0;
background: #ffff00;
background: -webkit-gradient(linear, left top, left bottom, from(#ff9900), to(#ffff00));
background: -webkit-linear-gradient(top, #ff9900, #ffff00);
background: -moz-linear-gradient(top, #ff9900, #ffff00);
background: -ms-linear-gradient(top, #ff9900, #ffff00);
background: -o-linear-gradient(top, #ff9900, #ffff00);
background-image: -ms-linear-gradient(top, #ff9900 0%, #ffff00 100%);
color: #fff;
}
.button:active {
text-shadow: #1e4158 0 1px 0;
border: 2px solid #d9ff00;
background: #ff9900;
background: -webkit-gradient(linear, left top, left bottom, from(#ffff00), to(#ffff00));
background: -webkit-linear-gradient(top, #ffff00, #ff9900);
background: -moz-linear-gradient(top, #ffff00, #ff9900);
background: -ms-linear-gradient(top, #ffff00, #ff9900);
background: -o-linear-gradient(top, #ffff00, #ff9900);
background-image: -ms-linear-gradient(top, #ffff00 0%, #ff9900 100%);
color: #000000;
}
#preview-frame {
margin: 0 auto;
display: block;
padding-top: 60px;
width:100%;
height: 581px;
}
<div id="headerfix">
<section style="width:15%; float:left;"><img style='padding-left: 10px; padding-top: 2.5px;' src="https://turnkey-shop.com/wp-content/uploads/2017/11/demo-tunkey-icon.png" alt="Turnkey-Shop.com"></section>
<section style='padding-left:15%; padding-top:8px; width:70%; text-align:center; float:none; font-size:25px; color:gold;'>Product Name</section>
<section style='padding-left:15%; width:70%; text-align:center; float:none; font-size:12px; color:gold;'>SKU</section>
<section style='padding-left:85%; width: 15%; float:none; '><a href='https://turnkey-shop.com/' class='button'>Buy Now</a></section>
</div>
<iframe id="preview-frame" src="https://turnkey-shop.com/" frameborder="0"></iframe>
I want my button to be center in the top bar.
Use margin-top property in the section to properly align your button
Fiddle: http://jsfiddle.net/sanchitpatiyal95/QQKc4/184/

how to add css for div tag

I want to display the div tag from top of 'rest' div tag.
'Rest' div tag is like container. I want to display the menu on left side and want to display the 'heading' div tag on the margin-top of the rest tag.
In my layout I drawn 'menu' div in green color which is correct.I want to display the div tag 'heading' on the position where I marked in red box.But my problem is now it is displayed in the botton which i drawn it in blue colored box.
.heading{
float:left;
margin-top:0px;
margin-left:170px;
height:25px;
width:79%;
background-color:#15317E;
}
.rest {
height: 685px;
background: -o-linear-gradient(bottom, #e5e3e3 5%, #ffffff 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #e5e3e3), color-stop(1, #ffffff));
background: -moz-linear-gradient(center top, #e5e3e3 5%, #ffffff 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr="#e5e3e3", endColorstr="#ffffff");
background: -o-linear-gradient(top, #e5e3e3, ffffff);
background-color: #e5e3e3;
border: 1px solid #f9f2f2;
border-width: 0px 0px 0px 0px;
border-radius: 0px 0px 10px 10px;
text-align: left;
padding: 0px 7px;
}
.sidemenu {
float: left;
margin-top: 150px;
height: 250px;
width: 150px;
border: 1px solid #f9f2f2;
border-radius: 10px;
}
.content {
border-left: thick solid #f9f2f2;
}
hr {
margin: 0;
margin-left:170px;
width: 1px;
height: 660px;
border:0;
background: #fff;
}
.menu{
height: 45px;
width: 150px;
text-align:left;
margin-left:2px;
background: -o-linear-gradient(bottom, #e5e3e3 5%, #ffffff 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #e5e3e3), color-stop(1, #ffffff));
background: -moz-linear-gradient(center top, #e5e3e3 5%, #ffffff 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr="#e5e3e3", endColorstr="#ffffff");
background: -o-linear-gradient(top, #e5e3e3, ffffff);
background-color: #e5e3e3;
border: 1px solid #f9f2f2;
border-width: 0px 0px 0px 0px;
border-radius: 0px 0px 10px 10px;
text-align: left;
padding: 0px 7px;
}
<div class="rest">
<div class="side">
<div class="sidemenu">
<div class="1 menu">
Profile
</div> <!--End of menu1 -->
<div class="2 menu">
Clients
</div> <!--End of menu 2-->
<div class="3 menu">
Employees
</div> <!--End of menu 3-->
<div class="menu 4">
Documents
</div> <!--End of menu 4-->
</div> <!--End of side menu -->
</div> <!--End of side div -->
<hr>
<div class="heading" >
</div> <!-- End of heading div -->
<div class="content">
</div> <!--End of content -->
</div> <!--End of rest div -->
Replace your .heading, hr and add new css .side class. I think that it will be solved.
.heading{
float: left;
margin-top: 0px;
margin-left: 0px;
height: 25px;
width: 66%;
background-color: #15317E;
}
.side{
width: 33%;
float: left;
display: inline-block;
}
hr {
margin: 0;
width: 1px;
height: 660px;
border: 0;
background: #fff;
float: left;
}
Demo
Try adding CSS class to .side and update .header
.heading{
float:left;
height:25px;
width:79%;
background-color:#15317E;
}
.rest {
height: 685px;
background: -o-linear-gradient(bottom, #e5e3e3 5%, #ffffff 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #e5e3e3), color-stop(1, #ffffff));
background: -moz-linear-gradient(center top, #e5e3e3 5%, #ffffff 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr="#e5e3e3", endColorstr="#ffffff");
background: -o-linear-gradient(top, #e5e3e3, ffffff);
background-color: #e5e3e3;
border: 1px solid #f9f2f2;
border-width: 0px 0px 0px 0px;
border-radius: 0px 0px 10px 10px;
text-align: left;
padding: 0px 7px;
}
.sidemenu {
float: left;
margin-top: 150px;
height: 250px;
width: 150px;
border: 1px solid #f9f2f2;
border-radius: 10px;
}
.content {
border-left: thick solid #f9f2f2;
}
hr {
margin: 0;
margin-left:170px;
width: 1px;
height: 660px;
border:0;
background: #fff;
}
.menu{
height: 45px;
width: 150px;
text-align:left;
margin-left:2px;
background: -o-linear-gradient(bottom, #e5e3e3 5%, #ffffff 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #e5e3e3), color-stop(1, #ffffff));
background: -moz-linear-gradient(center top, #e5e3e3 5%, #ffffff 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr="#e5e3e3", endColorstr="#ffffff");
background: -o-linear-gradient(top, #e5e3e3, ffffff);
background-color: #e5e3e3;
border: 1px solid #f9f2f2;
border-width: 0px 0px 0px 0px;
border-radius: 0px 0px 10px 10px;
text-align: left;
padding: 0px 7px;
}
.side{
float:left; width:19%;
}
Add these two css properties to your ".heading" in your css part
.heading{
position:absolute;
top:0;
}

Replicate image in CSS and HTML only

For a code quiz I am trying to replicate the attached image using CSS and HTML only. The gradients and borders seem to be working out fine, but I am having trouble getting the ribbon edges to look curved.
Here is my markup:
<div class="container">
<div class="ribbon-wrapper-green"><div class="ribbon-green">AWESOME!</div></div>
<div class="ribbon-bottom-left"></div>
<div class="bottom-left-gradient"></div>
And here is my CSS:
.container {
width:300px;
height:300px;
margin-left:auto;
margin-right:auto;
margin-top:10px;
position:relative;
border:#CCC 1px solid;
background-color:#EBEBEB;
box-shadow:1px 1px 1px #CCC;
}
.ribbon-wrapper-green {
width: 290px;
height: 290px;
overflow: hidden;
position: absolute;
top: -3px;
right: -3px;
}
.ribbon-green {
font: 25px Arial;
text-align: center;
text-shadow:0px 0px 6px #000;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
position: relative;
padding: 20px 0;
left: 7px;
top: 66px;
width: 363px;
background-color: #BFDC7A;
background-image: -webkit-gradient(linear, left top, left bottom, from(#BFDC7A), to(#8EBF45));
background-image: -webkit-linear-gradient(top, #BFDC7A, #8EBF45);
background-image: -moz-linear-gradient(top, #BFDC7A, #8EBF45);
background-image: -ms-linear-gradient(top, #BFDC7A, #8EBF45);
background-image: -o-linear-gradient(top, #BFDC7A, #8EBF45);
color: #FFF;
-webkit-box-shadow: 0px 8px 20px rgba(0,0,0,0.3);
-moz-box-shadow: 0px 8px 20px rgba(0,0,0,0.3);
box-shadow: 0px 8px 20px rgba(0,0,0,0.3);
}
.ribbon-green:before, .ribbon-green:after {
content: "";
border-top: 4px solid #6e8900;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
position:absolute;
bottom: -4px;
}
.ribbon-green:before {
left: 0;
}
.ribbon-green:after {
right: 0;
}
.ribbon-bottom-left {
width: 0px;
height: 0px;
border-style: solid;
border-width: 250px 0 0 250px;
border-color: transparent transparent transparent #D32023;
position:absolute;
bottom:-5px;
left:-5px;
border-top-left-radius:10px;
border-bottom-right-radius:10px;
-moz-border-radius-topleft:10px;
-moz-border-radius-bottomright:10px;
z-index:1;
}
.bottom-left-gradient {
position:absolute;
bottom:-8px;
left:-8px;
z-index:100;
height:245px;
width:245px;
opacity:0.4;
filter:alpha(opacity=40);
background: -moz-linear-gradient(45deg, rgba(255,255,255,1) 0%, rgba(255,255,255,0.92) 4%, rgba(255,255,255,0) 51%); /* FF3.6+ */
background: -webkit-gradient(linear, left bottom, right top, color-stop(0%,rgba(255,255,255,1)), color-stop(4%,rgba(255,255,255,0.92)), color-stop(51%,rgba(255,255,255,0))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(45deg, rgba(255,255,255,1) 0%,rgba(255,255,255,0.92) 4%,rgba(255,255,255,0) 51%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(45deg, rgba(255,255,255,1) 0%,rgba(255,255,255,0.92) 4%,rgba(255,255,255,0) 51%); /* Opera 11.10+ */
background: -ms-linear-gradient(45deg, rgba(255,255,255,1) 0%,rgba(255,255,255,0.92) 4%,rgba(255,255,255,0) 51%); /* IE10+ */
background: linear-gradient(45deg, rgba(255,255,255,1) 0%,rgba(255,255,255,0.92) 4%,rgba(255,255,255,0) 51%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#00ffffff',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
border-style:solid;
border-width:0 0 5px 5px;
border-radius:10px;
-moz-border-radius:10px;
border-color:#E41316;
}
The image is coming out like this example here: http://arunsood.me/code-quizzes/placebo-effect/.
The original I need to copy is below. How can I achieve the edge bending effect via CSS alone?

Navigation UL/LI additional space

It's one of those days and I can not figure out why I'm getting a space to the left of each of the LI tags in the following code. If you hover over, the menu items you'll see what I mean.
http://jsfiddle.net/midnitesonnet/C2Dub/
<div id="wrapper">
<div id="menu">
<ul>
<li>Home</li>
<li>Home</li>
<li>Home</li>
</ul>
</div>
<div id="content">Content</div>
<div id="footer">Footer</div>
</div>
I can not figure out why I'm getting a space to the left of each of the LI tags
Because you format them with display:inline-block - and have whitespace between the tags. That's basic "HTML behavior", that any whitespace between two inline(-block) elements is condensed to one space character when displayed.
Either float the LI instead, or write them without whitespace between the tags, meaning ...</li><li>...
try this
http://jsfiddle.net/C2Dub/4/
/* CSS Document */
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 0.9em;
margin-top: 0px;
background-color: #f5f5f5;
}
#wrapper {
background-color: #ffffff;
width: 1000px;
margin: auto;
-webkit-box-shadow: 0px 0px 6px rgba(50, 50, 50, 0.64);
-moz-box-shadow: 0px 0px 6px rgba(50, 50, 50, 0.64);
box-shadow: 0px 0px 6px rgba(50, 50, 50, 0.64);
/*-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;*/
}
#menu {
background: #505050;
background: -moz-linear-gradient(top, #505050 0%, #343434 50%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#505050), color-stop(50%,#343434));
background: -webkit-linear-gradient(top, #505050 0%,#343434 50%);
background: -o-linear-gradient(top, #505050 0%,#343434 50%);
background: -ms-linear-gradient(top, #505050 0%,#343434 50%);
background: linear-gradient(to bottom, #505050 0%,#343434 50%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#505050', endColorstr='#343434',GradientType=0 );
min-height: 26px;
color: #CCC;
}
#menu ul {
display: block;
height: 39px;
list-style: none outside none;
margin: 0;
padding: 0;
}
#menu li {
margin: 0;
display: inline-block;
height: 39px;
border-right: 1px solid rgb(0, 0, 0);
padding: 0px 20px !important;
line-height: 39px;
list-style: none;
float:left;
}
#menu li a {
display: inline-block;
width: 99%;
color: #CCC;
text-decoration: none;
}
#menu li:hover {
background: #6b6b6b;
background: -moz-linear-gradient(top, #6b6b6b 0%, #4c4c4c 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6b6b6b), color-stop(100%,#4c4c4c));
background: -webkit-linear-gradient(top, #6b6b6b 0%,#4c4c4c 100%);
background: -o-linear-gradient(top, #6b6b6b 0%,#4c4c4c 100%);
background: -ms-linear-gradient(top, #6b6b6b 0%,#4c4c4c 100%);
background: linear-gradient(to bottom, #6b6b6b 0%,#4c4c4c 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6b6b6b', endColorstr='#4c4c4c',GradientType=0 );
}
#content {
min-height: 600px;
padding: 5px;
}
#footer {
min-height: 50px;
background: #f4f7f5;
background: -moz-linear-gradient(top, #f4f7f5 0%, #edf5f7 37%, #d3e8e6 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f4f7f5), color-stop(37%,#edf5f7), color-stop(100%,#d3e8e6));
background: -webkit-linear-gradient(top, #f4f7f5 0%,#edf5f7 37%,#d3e8e6 100%);
background: -o-linear-gradient(top, #f4f7f5 0%,#edf5f7 37%,#d3e8e6 100%);
background: -ms-linear-gradient(top, #f4f7f5 0%,#edf5f7 37%,#d3e8e6 100%);
background: linear-gradient(to bottom, #f4f7f5 0%,#edf5f7 37%,#d3e8e6 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f4f7f5', endColorstr='#d3e8e6',GradientType=0 );
border-top: 1px #D2D2D2 solid;
}
This seems to work, I floated your li's, removed some padding and changed the height of the menu: http://jsfiddle.net/C2Dub/5/
#menu {
background: #505050;
background: -moz-linear-gradient(top, #505050 0%, #343434 50%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#505050), color-stop(50%,#343434));
background: -webkit-linear-gradient(top, #505050 0%,#343434 50%);
background: -o-linear-gradient(top, #505050 0%,#343434 50%);
background: -ms-linear-gradient(top, #505050 0%,#343434 50%);
background: linear-gradient(to bottom, #505050 0%,#343434 50%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#505050', endColorstr='#343434',GradientType=0 );
min-height: 39px;
color: #CCC;
}
#menu ul {
display: block;
padding: 0;
margin: 0;
list-style: none;
}
#menu li {
margin: 0;
float: left;
height: 19px;
border-right: 1px solid rgb(0, 0, 0);
padding: 10px 20px !important;
list-style: none;
}
U have some whitespace characters between your HTML code try to put the li tags on eachtoher:
<ul>
<li>Home</li>
<li>Home</li>
<li>Home</li>
</ul>
This solved the problem in the Fiddle.

force div to surround another div

At the moment I have a parent div containing 2 div's, both div's have their own border. What I try to do is to have 1 div in the left top corner and the other div surround it on the right and bottom with margin between them. Just like the image below:
Is this even possible, using css3 and html5?
Edit: Here is the layout of the div's.
<div id="main">
<div id="leftdiv">
Here is some text and an image displayed
</div>
<div id="rightdiv">
<div class="profile"><h4>Some text</h4><img src="...."></div>
<div class="profile"><h4>Some text</h4><img src="...."></div>
<div class="profile"><h4>Some text</h4><img src="...."></div>
<div class="profile"><h4>Some text</h4><img src="...."></div>
<div class="profile"><h4>Some text</h4><img src="...."></div>
..............
</div>
</div>
You could try to fake this effect with pseudo-elements for the top-left container.
.first {
position: relative;
float: left;
height: 30px;
width: 30px;
border: 1px solid black;
margin: 0 5px 5px 0;
}
.first:after {
content: '';
position: absolute;
top: -1px;
right: -5px;
height: 35px;
width: 3px;
background-color: #fff;
border-right: 1px solid black;
}
.first:before {
content: '';
position: absolute;
bottom: -5px;
left: -1px;
height: 3px;
width: 35px;
background-color: #fff;
border-bottom: 1px solid black;
}
.second {
height: 80px;
width: 100px;
border: 1px solid black;
}
See this fiddle:
http://jsfiddle.net/fqsDp/2/
I have the following in jsfiddle.com:
#main {
float: left;
width: 400px;
}
#leftdiv {
float: left;
margin: 0 0.5em 0.5em 0;
background: green;
color: black;
width: 150px;
height: 150px;
background: rgb(255,255,255);
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNkYmRiZGIiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(219,219,219,1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,1)), color-stop(100%,rgba(219,219,219,1)));
background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(219,219,219,1) 100%);
background: -o-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(219,219,219,1) 100%);
background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(219,219,219,1) 100%);
background: linear-gradient(to bottom, rgba(255,255,255,1) 0%,rgba(219,219,219,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#dbdbdb',GradientType=0 );
border: 1px solid #E2E2E2;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
#rightdiv {
background: rgb(255,255,255);
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNkYmRiZGIiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(219,219,219,1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,1)), color-stop(100%,rgba(219,219,219,1)));
background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(219,219,219,1) 100%);
background: -o-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(219,219,219,1) 100%);
background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(219,219,219,1) 100%);
background: linear-gradient(to bottom, rgba(255,255,255,1) 0%,rgba(219,219,219,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#dbdbdb',GradientType=0 );
border: 1px solid #E2E2E2;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
http://jsfiddle.net/5unJw/