I'm struggling to get my div (#content) to full 100% height of the page, if I resize my browser, my div (.divAboutRight) stretches accordingly to accommodate the content but my wrapper div (#content) does not? I have an image (#logo) which is centered to it's parent (#content) which it is not doing when the parent doesn't fill 100%.
I'm sure I'm missing something really basic.
Any assistance or guidance would be appreciated.
<style>
html{margin:0; padding:0; width:100%; height:100%;}
body{height:100%;min-height:100%; margin:0; padding:0; width:100%; background-color:#fb9f32; color:#FFF;}
.head{width:100%; height:60px; background-color:#FFFFFF;}
#content{width:100%;height:100%;min-height: 100%; position:relative; border:1px solid red;}
#Back
{
position:absolute;
left:0;
background:url(../images/Back.png) no-repeat;
background-size: 100% 100%;
float:left;
min-width:55%;
height:59%;
border:1px solid green;
}
#logo
{
display:block;
position: absolute;
top: 50%;
left: 50%;
max-height: 132px;
max-width: 133px;
margin: -66.5px 0 0 -66px;
z-index:9999999;
}
.divAboutRight{width:35%; margin-right:5%; margin-top:3%;float:right; border:1px solid yellow;}
</style>
<body>
<div class="head">
<!-- Header Content -->
</div>
<div id="content">
<div id="Back">
<!-- absolute positioned -->
</div>
<!-- Fixed logo to be center of content wrapper -->
<img id="logo" width="133" height="132" src="images/logo.png"/>
<div class="divAboutRight">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam id est leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In et volutpat metus. Cras et ante in enim sollicitudin facilisis quis eget lacus. Donec a justo in lacus ornare porttitor feugiat sit amet velit. Nunc iaculis, tellus quis sollicitudin placerat, leo nulla viverra lectus, id semper massa arcu in purus. Vivamus dictum venenatis metus quis viverra. Donec euismod, mauris vel aliquam convallis, lectus diam scelerisque lacus, id adipiscing orci augue nec arcu. Nulla molestie est lobortis tempor consectetur. Curabitur convallis malesuada velit et volutpat. Morbi a commodo velit. Integer malesuada nunc augue, ac convallis justo sollicitudin a. Nam nulla urna, facilisis quis ullamcorper dictum, venenatis eu ante. Ut consectetur sit amet lacus sed posuere. Nunc facilisis est eu ultrices scelerisque.
Cras feugiat tincidunt justo, et eleifend felis pretium ac. Nulla ornare, massa eu tincidunt tristique, sapien enim congue nisl, id pellentesque nisl lorem vel dolor. Mauris imperdiet, diam ac aliquam convallis, eros ante rhoncus justo, non malesuada mi nulla non sem. Interdum et malesuada fames ac ante ipsum primis in faucibus. Suspendisse potenti. Praesent sapien velit, sodales eget odio at, ullamcorper molestie nibh. Mauris iaculis posuere leo, non sollicitudin libero ullamcorper quis. Integer lobortis et eros vitae imperdiet. Ut ligula sem, tempor quis lobortis imperdiet, interdum ac nisl. Sed non lectus mauris.
Donec mattis lorem dolor, a feugiat neque dictum in. Nullam pharetra magna mi, quis hendrerit odio vestibulum id. Donec faucibus risus sed felis mattis pharetra vel a enim. Curabitur ultrices bibendum dapibus. Nulla sit amet metus mauris. Phasellus at tellus est. Mauris sagittis, eros quis laoreet sodales, tortor justo tempus dolor, et tincidunt dui tellus et erat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque vitae pulvinar sapien. Praesent pellentesque metus sem, pellentesque ullamcorper augue pellentesque eu.
In neque lectus, ultricies ultrices nisi sed, commodo viverra justo. Cras quis neque vulputate, elementum ante non, pellentesque urna. Fusce id tempus magna. Fusce nec tortor id nulla pharetra sodales nec at tellus. Suspendisse gravida felis non turpis consequat, sit amet gravida risus ornare. Interdum et malesuada fames ac ante ipsum primis in faucibus. Duis elementum consequat mauris ut accumsan. Donec nec aliquet tortor. Donec turpis tellus, convallis at faucibus sed, volutpat ac turpis. Vestibulum consequat sapien mi, et ultricies libero convallis ultricies. Mauris placerat mollis elementum. Nulla molestie felis purus, sed hendrerit enim vehicula ac. Curabitur adipiscing fringilla ultricies. Nunc hendrerit libero non aliquet egestas. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam mattis dui a enim interdum aliquet.
Nulla sagittis ligula enim, in vulputate lectus tincidunt ac. Sed imperdiet gravida orci at semper. Proin mollis adipiscing neque, vitae convallis risus rutrum eget. Praesent augue neque, lacinia nec tincidunt sed, elementum non sem. Suspendisse a mi condimentum, pellentesque lorem id, tempor turpis. In tortor nibh, convallis egestas ornare scelerisque, semper non nisi. Pellentesque ullamcorper euismod malesuada. Curabitur condimentum arcu id lorem posuere tincidunt. Proin convallis, elit vel fringilla tincidunt, eros diam ullamcorper lacus, eget posuere tortor velit vestibulum lorem. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Cras sit amet pellentesque lacus. Maecenas molestie augue id ipsum feugiat, non pulvinar mi eleifend. Aenean augue metus, tincidunt non pellentesque eu, tristique quis metus. In a neque viverra, commodo velit ut, pretium diam.
</div>
</div>
</body>
From what I can see, Your div #content does not cover the full height because you have a div .head with a height of 60px;
Yo can either float your .head div or make it's position:absolute;
You could also include the .head div iside the #content div like this:
<body>
<div id="content">
<div class="head">
<!-- Header Content -->
</div>
<div id="Back">
<!-- absolute positioned -->
</div>
<!-- Fixed logo to be center of content wrapper -->
<img id="logo" width="133" height="132" src="images/logo.png"/>
<div class="divAboutRight">
<!-- Dynamic Content -->
</div>
</div>
</body>
If you are OK supporting IE9+, here is the code:
<style>
#content{
.
.
height:calc(100% - 60px);
.
}
</style>
Calc is supported in all modern browsers now.
On the other hand, if you can't support calc, here is one more way:
<style>
.head {
... // rest of head's css
z-index: 2;
}
#content {
position: relative;
box-sizing('border-box');
height: 100%;
padding-top: 60px; // height equal to the header
margin-top: -60px; // this will offset your content up again
z-index: 1; // make the content go BEHIND the head
... // rest of the CSS
}
</style>
note: this will make the scrollbar start from behind the head, because the content will be under the head.
Related
So what my goal is, is to position this div background box "lightgrey", with the text which is in another div, but everytime i get the divs positioned the way I want, they seem to be offset, I was thinking of creating a #media_query but I felt like I would have to create way too many statements to have it adjust accordingly, if anyone has any suggestions that would be great.
<div style="width:200px; height:200px;right:0;margin-right:7%; border: 5px;
solid:grey; background-color:lightgrey;position:absolute;">
</div>
<div style="position:absolute;right:0;margin-right:10%;">
<h3>{{major_choice.0.Major}}</h3>
<h3>Overall Rating:</h3>
<h3>{{major_choice.0.ProfessorRating}}</h3>
</div>
The first image is of a map leaflet that does what I want to achieve and its essentially dynamically changing the size without losing its position, verses what I created which constantly moves out of position when i resize the screen.
Leaflet Map (my goal):
This first image is ideal with how I would want it positioned:
When I resize this happens:
I don't have a ton of experience with css, I'm in a web development class right now, but I wont be able to see my professor because of the holidays, if anyone could give me some suggestions I would really appreciate it!
Any suggestions?
html code: https://pastebin.com/iTmsyV5Z
I can't really get a full example working to test but something like:
<div style="width: 200px; height:200px; border: 5px;
solid:grey; background-color: lightgrey; float: left;">
</div>
<div style="margin-left:10%; float: left;">
<h3>{{major_choice.0.Major}}</h3>
<h3>Overall Rating:</h3>
<h3>{{major_choice.0.ProfessorRating}}</h3>
</div>
or
<div style="width: 200px; height:200px; border: 5px;
solid:grey; background-color: lightgrey; float: left;">
</div>
<div style="margin-right:10%; float: right;">
<h3>{{major_choice.0.Major}}</h3>
<h3>Overall Rating:</h3>
<h3>{{major_choice.0.ProfessorRating}}</h3>
</div>
Should work after some adjustments of the values. Not sure if you want the grey box all the way to the right or left.
I achieved this by using relative positioning. And floating both elements left so they stack horizontally. I believe this is what you wanted.
By adding the element within your main container, absolute positioning will work nicely. This will then scroll with the container. If you require it to stay where it is on the screen, you will need to use fixed positioning, it will then be relative to your viewport. So keep in mind when adjusting your top and right positioning to compensate.
.Menu,
.Content {
position: fixed;
background-color: #CCC;
left: 10%;
right: 10%;
}
.Menu {
top: 10px;
height: 50px;
}
.Content {
top: 70px;
bottom: 10px;
overflow: auto;
padding-right: 250px;
}
.Floating {
position: absolute;
background-color: #EDEDED;
right: 20px;
top: 20px;
width: 210px;
height: auto:
}
<div class="Menu">
This is the menu
</div>
<div class="Content">
<div class="Floating">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer euismod lectus eros, placerat euismod nisl pharetra eget. Fusce commodo ipsum non ipsum fringilla dignissim. Integer eu mi ligula. In hac habitasse platea dictumst. Cras aliquet luctus felis
nec rutrum. In in magna eros. Donec tellus ipsum, auctor et eleifend non, mollis quis mauris. Praesent cursus malesuada mattis.
</div>
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer euismod lectus eros, placerat euismod nisl pharetra eget. Fusce commodo ipsum non ipsum fringilla dignissim. Integer eu mi ligula. In hac habitasse platea dictumst. Cras aliquet luctus
felis nec rutrum. In in magna eros. Donec tellus ipsum, auctor et eleifend non, mollis quis mauris. Praesent cursus malesuada mattis. Morbi id quam libero. Donec laoreet ullamcorper lobortis. Etiam quis est ac lacus varius malesuada. Nunc venenatis
rutrum dui, id euismod nunc porttitor id. Nulla id sapien imperdiet, ullamcorper felis et, rhoncus tortor. Quisque purus tellus, molestie a urna in, bibendum bibendum mauris. Nunc aliquet ornare tincidunt. Praesent leo diam, fermentum nec tempor in,
pellentesque eget velit. Aenean luctus mauris et turpis vehicula, at tristique ex gravida. Vivamus finibus, tellus vel volutpat facilisis, enim metus mattis mi, quis dictum tortor mi a mauris. Pellentesque malesuada tellus non consectetur feugiat.
Proin rutrum sem nec odio varius tincidunt. Quisque egestas enim et orci scelerisque, quis viverra lectus tristique. Donec consectetur, lacus sed vehicula lacinia, ipsum arcu consequat odio, sed porta erat neque eu lacus. Proin consequat quam vitae
nisl vulputate, ut imperdiet justo ultricies. Phasellus dictum vestibulum ullamcorper. Quisque lobortis eros sed ante porta ultricies. Suspendisse sit amet purus non enim fringilla pellentesque. Sed posuere, metus ut venenatis pretium, enim urna laoreet
sapien, accumsan condimentum mauris nisi sed elit. Nunc mollis sit amet enim ac placerat. Donec elementum consectetur ipsum in molestie. Fusce auctor sollicitudin lorem a pharetra. Vestibulum blandit consectetur sagittis. Nullam varius commodo dictum.
Sed tempus a nulla nec feugiat. Sed pharetra mattis velit sed sollicitudin. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean sit amet vehicula felis. Nullam faucibus interdum rhoncus. Proin eget velit non
nunc dignissim vestibulum sit amet id nulla. Nunc a lectus mauris. Sed sagittis orci ullamcorper nisi ullamcorper dictum. Etiam ut tellus tortor. In a molestie tortor. Quisque turpis tellus, fermentum euismod eros a, vulputate aliquam sapien. Integer
nunc dui, scelerisque nec interdum id, auctor ut ante. Curabitur pharetra dui vitae tellus tincidunt auctor. Etiam eget fringilla massa. Phasellus auctor lorem hendrerit massa porttitor, luctus consequat leo semper. Curabitur sollicitudin est sapien,
sed vulputate neque finibus ac. Aliquam pulvinar enim ac mi congue, eu dapibus velit imperdiet. Suspendisse pretium tellus eu urna auctor, quis sodales erat varius. Aenean eget felis mi. Suspendisse non tellus in mauris congue finibus et et risus.</div>
</div>
I have this code:
/**
* CSSReset.com - How To Keep Footer At Bottom of Page with CSS
*
* Original Tutorial: http://www.cssreset.com/2010/css-tutorials/how-to-keep-footer-at-bottom-of-page-with-css/
* License: Free - do whatever you like with it! Credit and linkbacks much appreciated.
*
* NB: Make sure the value for 'padding-bottom' on #content is equal to or greater than the height of #footer.
*/
html,
body {
margin:0;
padding:0;
height:100%;
}
#wrapper {
min-height:100%;
position:relative;
}
#header {
background:#ededed;
padding:10px;
}
#content {
padding-bottom:100px; /* Height of the footer element */
}
#footer {
background:#ffab62;
width:100%;
height:100px;
position:absolute;
bottom:0;
left:0;
}
<!DOCTYPE html>
<!--[if lt IE 7]>
<style type="text/css">
#wrapper { height:100%; }
</style>
<![endif]-->
<body>
<div id="wrapper">
<div id="header">
</div><!-- #header -->
<div id="content">
</div><!-- #content -->
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam vel tellus eros. Cras id sapien vulputate, molestie mauris convallis, vestibulum mi. Nullam vestibulum interdum massa, quis feugiat dolor venenatis id. Nulla pellentesque pharetra consectetur. Curabitur placerat neque sed ex mattis lobortis. Quisque vitae hendrerit urna. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed odio sem, hendrerit in tortor in, cursus aliquam orci. Etiam sed dolor lobortis, fringilla elit nec, tincidunt odio. Maecenas et consectetur ante, quis ullamcorper ex. Quisque tempor mollis mattis. Aliquam tempus tellus eu posuere ullamcorper. Duis tempor libero vel quam accumsan congue.<br><br>
Curabitur porta congue eros eu vulputate. Donec a lacus a ante accumsan faucibus sit amet sit amet enim. Aliquam erat volutpat. Vivamus interdum dui nisi, sed placerat tortor consectetur at. Aenean volutpat ex non risus sagittis, nec pulvinar justo consequat. Proin eget nibh quis erat suscipit pulvinar. Etiam varius neque id dui volutpat, nec tempor eros venenatis. In ullamcorper dignissim lorem quis imperdiet.<br><br>
Nunc hendrerit maximus dignissim. Pellentesque eget dui erat. Curabitur sed justo accumsan, varius elit eu, fringilla ligula. Fusce varius magna id blandit placerat. Etiam aliquam nunc sed pulvinar tincidunt. Nullam ut sodales tellus. Mauris bibendum pretium dui a lobortis. Suspendisse sit amet consectetur nisl. Aliquam enim sem, tincidunt ut molestie ornare, tristique ut nibh. Nam lacinia scelerisque tortor, eget pretium eros aliquam quis. Mauris volutpat quis tellus eu pharetra. Ut a cursus turpis. Cras placerat ante sit amet leo ultricies convallis.<br><br>
Curabitur sollicitudin iaculis porta. Proin tellus libero, laoreet ut eros vitae, ultricies vestibulum est. Pellentesque iaculis, risus eget eleifend blandit, dui nisl venenatis mauris, at finibus orci turpis sit amet ligula. Nunc sed nisi sit amet diam congue maximus eget at metus. Duis suscipit magna a tortor porta laoreet. Donec ac magna non turpis porta varius eget ac urna. Cras et nibh odio. Nullam vitae sem justo. Morbi laoreet vehicula sem, elementum maximus erat egestas id. Curabitur id eros purus. Nullam eget nibh a augue tristique interdum nec eu nunc. Suspendisse potenti. Ut sed finibus eros. Ut in tortor et neque cursus tempor et sit amet orci.<br><br>
<div id="footer">
</div><!-- #footer -->
</div><!-- #wrapper -->
</body>
In IE 11.0 all ok, but in FF and Chrome there is a small vertical scrollbar. If I change in #footer bottom:0; to bottom:5px; all ok. But why? Not critical but I would be very interested how can I avoid it.
I tried to set z-index to under body for some element with position fixed
example below:
HTML
<body>
<div class="fixed-top">
<ul>
menu content ....
</ul>
<div class="fixed-right">
<ul>
menu content .....
</ul>
</div>
</div>
<div class="main-content">
</div>
</body>
CSS
.fixed-top{
position:fixed;
z-index: 1030;
top: 0;
left: 0;
background: red;
height: 80px;
width: 100%;
}
.fixed-right{
position: fixed;
z-index: -1;
background: green;
width: 280px;
right: 0;
left: auto;
top: 0;
bottom: 0;
}
for fixed-top menu display top of content is OK , so fixed-right content I need display under all body content , but it is always at the top , why?
Fiddle
UPDATE
thank for all help :
Fiddle added here
http://jsfiddle.net/jimmyphong/0dsx3b29/
Now I want right menu under at all - under top menu , under body , it is possible.
Yeah its possible, however you will need to change your DOM tree.
.fixed-top{
position:fixed;
z-index: 1030;
top: 0;
left: 0;
background: red;
height: 80px;
width: 100%;
}
.fixed-right{
position: fixed;
z-index: -1;
background: green;
width: 280px;
right: 0;
left: auto;
top: 0;
bottom: 0;
}
.main-content{
z-index: 0;
background: #fff;
position: relative;
}
<body>
<div class="fixed-top">
<ul>
menu content ....
</ul>
</div>
<div class="fixed-right">
<ul>
menu content .....
</ul>
</div>
<div class="main-content">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus non facilisis turpis. Aliquam metus neque, interdum a felis sit amet, vehicula convallis augue. Suspendisse consequat, est quis hendrerit vehicula, nisl nulla consectetur erat, et auctor sem mi ac velit. Quisque cursus diam id est dapibus commodo. Pellentesque ultrices pretium nisi, in lacinia leo convallis et. Cras eu vestibulum turpis, non auctor quam. In ac mi placerat, eleifend quam nec, iaculis urna. Vestibulum pharetra sit amet metus nec pretium. Praesent et ante mauris. Quisque condimentum ante in elit mattis, et venenatis massa cursus. Fusce vitae nisl volutpat, tempor risus eu, facilisis quam. Mauris vitae condimentum lacus. Duis eget dolor in magna vestibulum vehicula.</p>
<p>Sed pulvinar, massa et sagittis dignissim, lacus lacus finibus eros, sed dictum velit est a lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Quisque semper eros vel sapien hendrerit, eu suscipit orci feugiat. Suspendisse aliquam lorem at molestie facilisis. Interdum et malesuada fames ac ante ipsum primis in faucibus. Aenean sit amet sollicitudin urna. Praesent ullamcorper nibh ut semper pellentesque. Morbi quis dapibus lorem. Pellentesque pulvinar felis in ipsum mollis tristique. Fusce pellentesque tortor sit amet dolor euismod, et posuere nisl cursus. Donec eget pharetra tortor. Quisque massa enim, tincidunt ac ex et, condimentum imperdiet arcu. Etiam suscipit dolor lorem, nec pharetra est lacinia vitae.</p>
<p>Donec varius nulla ac convallis eleifend. Quisque sit amet leo sodales, varius lacus quis, mattis nisl. Cras nisl leo, maximus eget scelerisque at, dignissim eu ex. Nulla dignissim convallis diam molestie finibus. Quisque volutpat faucibus pulvinar. Sed posuere tortor iaculis aliquet elementum. Fusce dignissim ornare lectus, ac dignissim dui consectetur non. Proin id sollicitudin lorem. Maecenas augue sem, semper non condimentum sed, finibus eu sapien.</p>
<p>Sed ac cursus sem, quis facilisis justo. Vestibulum laoreet gravida risus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi pellentesque commodo diam ut semper. Nam quam mauris, rhoncus vitae purus nec, consectetur tincidunt libero. Maecenas sollicitudin, diam id gravida elementum, odio purus dapibus quam, lobortis semper mauris est mollis enim. Vestibulum quis ante pulvinar, hendrerit est et, posuere dui. Integer quis semper elit, a sodales nunc. Nam eget tincidunt dolor. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus a mi aliquet, vestibulum velit sit amet, sodales urna.</p>
<p>Nulla pulvinar libero ligula, in placerat orci rhoncus vitae. Nunc rhoncus arcu sed magna ullamcorper, ac euismod felis tempus. Nunc molestie tempor magna, id rhoncus lorem feugiat non. Mauris efficitur justo felis, a consectetur magna posuere nec. Maecenas hendrerit eros egestas nibh sodales rutrum. Mauris ligula urna, semper non bibendum ac, volutpat ac magna. Etiam blandit, dolor et malesuada pretium, magna sem tristique diam, nec pharetra ante metus aliquam libero. Pellentesque vel orci nec tellus sagittis accumsan. Nulla facilisi. Nunc tempor pulvinar nulla id aliquam. Maecenas pharetra, leo id bibendum finibus, justo erat vulputate diam, at feugiat quam erat ut leo. Quisque risus leo, dapibus et nunc a, consectetur mollis elit. In et vehicula quam, ut suscipit odio. Sed nec ornare ipsum. Aenean semper ante in eros rhoncus fermentum. Fusce congue felis nunc, sed bibendum elit pellentesque vitae.</p>
</div>
</body>
Just move the .fixed-right div to be the sibling of .fixed-top, instead of the child
I'm trying to make a div fill the entire doc height, not just the viewpoint height. When 100% height is set on body, html and the div, the div will fill 100% of the viewpoint. However, when another div make the doc height go beyond the viewpoint, and the page is scrolled, the 100% height stayed at the original viewpoint height.
I've make the follow jsfiddle to demonstrate the problem:
http://jsfiddle.net/728CA/1/
Sorry if this is a repeat question, I have looked through many others questions and can't find an answer which works for my problem. I'm new to developing responsive sites, and I'd really appreciate some help.
css:
body, html {
height:100%;
}
#sidebar {
height:100%;
width:100px;
background:#FF00FF;
float:left;
}
#content {
width:200px;
float:left;
}
.clear {
clear:both;
html:
<div id="sidebar">
<nav>
Links
</nav>
</div>
<div id="content">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin id magna iaculis, tincidunt lacus et, gravida sapien. Sed velit metus, congue ac porttitor ut, ornare euismod tortor. Fusce ultricies pulvinar ante, eget facilisis leo rutrum eu. Donec turpis dui, elementum tristique lectus vel, semper posuere nisi. Curabitur at adipiscing lectus. Duis consectetur, urna sit amet feugiat vestibulum, sapien massa facilisis lectus, vitae sagittis augue tellus et augue. Quisque vitae nisi at metus interdum mollis. Vivamus in nisi placerat, rutrum sapien varius, dapibus est. Integer pharetra enim sem, nec porttitor velit suscipit vitae. Ut suscipit, sapien eget placerat congue, justo elit sagittis arcu, a elementum dolor leo a ante. Suspendisse auctor laoreet orci, ut varius est consequat vitae. In eu libero at libero faucibus eleifend et id magna. Vivamus molestie mi eu massa aliquam, sit amet ullamcorper ante semper. Mauris dictum orci id ante porta euismod. Quisque in ultrices sapien. Ut euismod dui ac justo egestas suscipit.
Integer vitae pretium eros. Suspendisse sapien ipsum, feugiat sed lorem sed, vestibulum lacinia sapien. Proin quis risus at massa lobortis porta. Vestibulum pretium rhoncus dui quis volutpat. Nullam nulla erat, bibendum at mauris et, imperdiet cursus turpis. Cras quis tellus sed urna sagittis rutrum lobortis eu elit. Fusce volutpat venenatis augue a fermentum. Praesent luctus tortor felis, eget varius lacus mattis eu. Aliquam tempor, mi at venenatis ultrices, erat metus mattis risus, id convallis ante mauris quis ipsum. Pellentesque vitae sodales purus. Sed eu faucibus tellus. Nam ultricies lorem enim, vitae vestibulum risus hendrerit ac. Integer condimentum orci in arcu vehicula porta. Ut euismod tincidunt justo, ac feugiat massa. Sed id sollicitudin purus.
</div>
<div class="clear"></div>
Look at my update
jsfiddle
I've made a container with pink background and the content has white background.
<div id="container">
<div id="sidebar">
<nav>
Links
</nav>
</div>
<div id="content">
</div>
<div class="clear"></div>
</div>
CSS
#container {
min-height:100%;
background:#FF00FF;
width: 300px;
}
#sidebar {
width:100px;
float:left;
}
#content {
width:200px;
float:left;
background:#FFFFFF;
}
I have a menu on the left side of my page and the content on the rest of the page. I have a dark, textured background so I want a semi-transparent background for the leftmenu div and a semi-transparent background for the content div. However, it seems like the body div is overlapping the menu div and stacking its transparency and also making the content of the menu div transparent.
I would rather have a space between the two sections. Could someone take a look at my code and offer a suggestion?
I have some code listed below but take a look at the jsfiddle to get the full picture.
http://jsfiddle.net/5xmze/ (Note, the links should be the same color as the header)
CSS:
#body{
padding-left:2px;
width: 85%;
position: relative;
background-color:rgba(0,0,0,0.6);
}
#leftside {
float: left;
width: 15%;
height: 100%;
}
HTML:
<div><span id="leftside">
<ul class="leftmenu">
<li class="leftmenu">Home</li>
<li class="leftmenu">Projects</li>
<li class="leftmenu">Resume</li>
<li class="leftmenu">Contact</li>
</ul></span>
</div>
<div id="body">
Content here...
</div>
Here's what I'm attempting to accomplish:
The best way would be to put the menu, and the body into the same parent div, then float:left; the body so it shows up beside the menu.
Don't forget to set a width to both elements, because if #body's width is bigger than space available on the page, it will show up under the menu.
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready( function(){
$(window).resize( function() {
var s = $("body").width();
$("body").css({ "min-width":s+"px" });
});
});
</script>
<style>
/* style.css */
body {
font-size: 1em;
background-image:url('http://i1358.photobucket.com/albums/q764/kenny_johnson5/blackorchid_zpsc8d78a87.png');
color:#FFF;
font-family:Arial;
width:85%;
margin-left:16%;
}
h1 {
font-family:Cambria,Serif;
color:#81E500;
text-align:center;
}
#top{
width: 85%;
position: relative;
}
#body{
padding-left:90px;
width: 85%;
position: relative;
background-color:rgba(0,0,0,0.6);
}
a {
color:#81E500;
font-family:Cambria,Serif;
font-size:1.5em;
}
#leftside {
float: left;
width: 15%;
height: 100%;
margin-left:-15%;
z-index:999;
}
ul.leftmenu {
list-style-type:none;
margin:0px;
padding:1px;
background-color:rgba(0,0,0,0.6);
border: 1px solid;
border-color:#000;
height:100%;
}
li.leftmenu {
padding:5px;
}
</style>
<html>
<div><div id="leftside">
<ul class="leftmenu">
<li class="leftmenu">Home</li>
<li class="leftmenu">Projects</li>
<li class="leftmenu">Resume</li>
<li class="leftmenu">Contact</li>
</ul></div>
</div>
<div id="body">
<div id="top">
<h1>Header</h1>
</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus tincidunt erat sit amet dolor imperdiet dignissim. Nunc eu enim erat. Suspendisse commodo faucibus risus at facilisis. Phasellus tortor urna, fringilla sed blandit non, porta vel enim. Vivamus placerat, risus et molestie elementum, risus elit dignissim elit, non porttitor nisl tortor sed lorem. Maecenas scelerisque mattis massa, vel blandit erat blandit sed. Vivamus erat augue, varius ac aliquet non, commodo id massa. Maecenas sit amet est posuere turpis ultrices aliquam. Nulla feugiat ultrices diam vitae egestas. Phasellus risus augue, dapibus nec condimentum non, tempus eu massa. Etiam sodales sodales dolor eu convallis.
</p>
<p>
Aenean in dignissim metus. Suspendisse placerat pharetra justo, et tristique neque vestibulum non. Quisque malesuada scelerisque diam eget suscipit. Donec non sollicitudin justo. Etiam sit amet massa felis. Maecenas aliquet cursus tristique. Etiam sollicitudin augue in risus venenatis rhoncus. Pellentesque tellus diam, porttitor in dapibus eu, rutrum eu lectus. Vestibulum luctus hendrerit augue vitae interdum. Donec in turpis malesuada arcu tempor placerat. Aliquam eget nisl ipsum. Cras blandit elementum vulputate. Ut vulputate ullamcorper urna, quis congue mauris laoreet nec. Morbi vitae dui eros.
</p>
<p>
Phasellus rhoncus ultrices sem et dictum. Ut ut nisl eget eros porttitor commodo auctor vitae leo. Quisque sed nulla augue, vel venenatis augue. Pellentesque bibendum sodales lectus, quis malesuada risus consectetur a. Aliquam lobortis aliquet vulputate. Duis sed velit est, in venenatis est. Vivamus viverra lacinia sapien non sodales. Aenean eleifend quam diam, id gravida tellus. Praesent dui sem, volutpat eu blandit in, volutpat ornare nulla. Nunc sed eros dolor.
</p>
<p>
Quisque sit amet diam nisl, volutpat interdum arcu. Proin et justo lorem. Mauris vitae egestas lacus. Nullam ut laoreet turpis. Donec eget metus enim, id porta orci. Nam condimentum feugiat tempor. Nunc ultricies pellentesque euismod. In hac habitasse platea dictumst. Etiam fringilla bibendum sapien, eu vestibulum nisi imperdiet tempus. Duis tincidunt magna id sapien porta vel aliquam massa tincidunt. Maecenas ut metus id augue congue scelerisque id nec enim. Ut ac nibh est, et laoreet orci. Nulla fermentum laoreet augue, in vulputate risus varius vel. Sed ac nunc quis tortor scelerisque rutrum.
</p>
<p>
Nullam adipiscing ultricies lacus ac pretium. In hac habitasse platea dictumst. Nullam convallis libero non augue sollicitudin mattis. Nunc commodo pharetra magna, tempor sagittis sem vehicula nec. Quisque massa ligula, gravida nec fringilla quis, tempus vel dolor. Nam et sem bibendum mi consectetur tincidunt. Nam placerat venenatis odio sit amet imperdiet. Integer luctus quam quis quam lobortis aliquam. Cras dignissim semper erat, ac laoreet leo volutpat quis. </p>
</div>
</body>
</html>