I want to add a fixed sidebar like in the picture below.
How is that possible?
Appreciate any suggestion.
Solution
used to this
fixed position
.sidebar{
position:fixed;
left:0;
width:250px; // width change to according your left bar side
top:0;
bottom:0;
}
Demo
.SomeClass { position: fixed }
This fiddle might solve your problem, with right column being flexible and left column fixed
http://jsfiddle.net/R5TZH/
<div class="container">
<div class="columns">
<div class="right-col">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum
</div>
</div>
<div class="left-col">
<a class="selected" href="#">05 <br><strong>Today</strong></a>
06 <br><strong>TOM</strong>
07 <br><strong>MON</strong>
08 <br><strong>TUE</strong>
09 <br><strong>WED</strong>
08 <br><strong>THU</strong>
09 <br><strong>FRI</strong>
</div>
</div>
CSS:
.container {
width: 100%;
}
.left-col {
background: none repeat scroll 0 0 #434345;
float: left;
margin-left: -100%;
padding: 10px;
width: 80px;
}
.left-col a {
background: none repeat scroll 0 0 #FFFFFF;
border-radius: 10px 10px 10px 10px;
color: #000000;
float: left;
font-size: 18px;
height: 50px;
margin-bottom: 10px;
padding: 10px;
text-align: center;
width: 60px;
}
.columns {
float: left;
width: 100%;
}
.right-col {
margin-left: 100px;
background:red;
height:400px;
}
for fixed side bar, style
position:fixed;
this will do but not in chrome, so you may use this
position:absolute;
top:0;
left:0;
bottom:0;
width:180px;// you may change as per your requirement
this works in all browsers :)
Edit : updated fiddle with content div
http://jsfiddle.net/MarmeeK/nkprH/5/
I hope this will do, for more answer post some of your work in details, thank you
Related
I want to add animated or gify image(Doctor treating pateint) on my website background, can anyone please suggest me with some solution, its a single page website: http://bighealth.co.in/
you can do like this:
change the url to the gif you want
change background-size: cover; to modify the way you want to display
body{
background-image: url('https://www.nasa.gov/sites/default/files/thumbnails/image/dscovrepicmoontransitfull.gif');
/* background-size: cover; */
}
If you want "high definition" animation, you need to add video as a background, if you mean this, then you need to provide the video in 3 types (.mp4, .ogg (or .ovg), webm), actually .mp4 could be enough, but will not work 100% in all brwosers, anyway here is the code:
.fullscreen-bg {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
overflow: hidden;
z-index: -100;
}
.fullscreen-bg__video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
#media (min-aspect-ratio: 16/9) {
.fullscreen-bg__video {
height: 300%;
top: -100%;
}
}
#media (max-aspect-ratio: 16/9) {
.fullscreen-bg__video {
width: 300%;
left: -100%;
}
}
#media (max-width: 767px) {
.fullscreen-bg {
background: url('../img/videoframe.jpg') center center / cover no-repeat;
}
.fullscreen-bg__video {
display: none;
}
}
<div class="fullscreen-bg">
<video loop muted autoplay poster="img/videoframe.jpg" class="fullscreen-bg__video">
<source src="http://dev2.slicejack.com/fullscreen-video-demo/video/big_buck_bunny.mp4" type="video/mp4">
<source src="http://dev2.slicejack.com/fullscreen-video-demo/video/big_buck_bunny.ogv" type="video/ogg">
<source src="http://dev2.slicejack.com/fullscreen-video-demo/video/big_buck_bunny.webm" type="video/webm">
</video>
</div>
<div class="content">
<h1>Full screen HTML5 video background</h1>
<p>Lorem ipsum dolor sit amet, vix te quidam commodo placerat. Mei ne dicunt minimum disputationi, purto everti adolescens id cum, quis veritus cotidieque eum ex. Ea eirmod atomorum posidonium sed, splendide dissentiunt an mel. Dolorem suavitate voluptatibus pro no. No duo conceptam cotidieque.</p>
<p>Pro novum argumentum ad. Vix at inani civibus, congue veritus probatus ad vel. Eam ne quis omnesque euripidis, pri ea dicat etiam ponderum. At sit harum dolor persius, eos vocent adipisci ad, magna movet audiam pri no. Erant labores incorrupte id sit, constituto scripserit theophrastus quo no.</p>
<p>Nam tacimates laboramus cu. Graeco tritani mel no. Iriure constituam mea te, quo integre salutatus ne. Case tota dicam te eam, quis minim assentior ei cum, sea eu verterem liberavisse. Modus officiis fabellas ea eos, in vis omittam ocurreret. Ea labitur assentior vix.</p>
<p>Case tation integre sit an. Te cum mollis vocent similique, docendi volumus eu nam. Erant euismod partiendo nec ei. Vel malorum liberavisse cu. Fabulas efficiantur in duo.</p>
<p>Ad qui brute fabulas rationibus, ex virtute omnesque vituperata vix. Ne case verterem probatus sit. In eam nulla tation debitis, has te alterum equidem definiebas. At summo facilisis eum. Vel ad nostro discere oportere, ad quod vitae officiis quo.</p>
<p>Case tation integre sit an. Te cum mollis vocent similique, docendi volumus eu nam. Erant euismod partiendo nec ei. Vel malorum liberavisse cu. Fabulas efficiantur in duo.Ad qui brute fabulas rationibus, ex virtute omnesque vituperata vix. Ne case verterem probatus sit. In eam nulla tation debitis, has te alterum equidem definiebas. At summo facilisis eum. Vel ad nostro discere oportere, ad quod vitae officiis quo.</p>
</div>
(click full page version to see the code running well, if run snippet not worked here, or visit the original source here)
The source of this code and more description provided here: https://slicejack.com/fullscreen-html5-video-background-css/
I need to create a curved, gradient box shadow in the shape of an ellipsis, which needs to be horizontally centered behind a div and offset to the bottom.
This is my markup:
<div class="about-tru">
<div class="container">
<h2 class="text-center heading">Welcome To TruCircles</h2>
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<div class="col-sm-4 text-center"><img src="img/trucircles-img.jpg" alt="trucircles-image" class="img-responsive"></div>
<div class="col-sm-7"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam facilisis dolor metus, sed feugiat diam finibus vitae. Sed dolor justo, consequat vel vulputate vitae, venenatis efficitur nibh. Vivamus blandit at nulla vel tempor. Nullam sodales nibh lorem, sed elementum lorem imperdiet sed. In in felis feugiat, laoreet nisl sit amet, blandit turpis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vestibulum dolor ut ligula ultricies, a ornare mauris interdum. Phasellus sollicitudin urna ac tortor elementum euismod.</p>
</div>
</div>
</div>
</div>
</div>
do you want a shadow of 50% width and in the middle of the div.about-tru, check the fiddle I've created -
http://jsfiddle.net/nw6vzd3L/
Something like this ?
.about-tru{
box-shadow : 0 0 20px;
border-radius: 6px;
margin : 10px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="about-tru">
<div class="container">
<h2 class="text-center heading">Welcome To TruCircles</h2>
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<div class="col-sm-4 text-center"><img src="http://tododepende.com/wp-content/uploads/2013/09/lorem_ipsum.gif" alt="trucircles-image" class="img-responsive"></div>
<div class="col-sm-7"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam facilisis dolor metus, sed feugiat diam finibus vitae. Sed dolor justo, consequat vel vulputate vitae, venenatis efficitur nibh. Vivamus blandit at nulla vel tempor. Nullam sodales nibh lorem, sed elementum lorem imperdiet sed. In in felis feugiat, laoreet nisl sit amet, blandit turpis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vestibulum dolor ut ligula ultricies, a ornare mauris interdum. Phasellus sollicitudin urna ac tortor elementum euismod.</p>
</div>
</div>
</div>
</div>
</div>
As far as I know you can't make an actual css-shadow in the shape of an ellipsis (which as far as I understand is what you want to achieve).
But you can fake it very well with a gradient background - for example on a pseudo-element:
CSS
.round_shadow {
position: relative;
border-radius: 5px;
position: relative;
border: 1px solid #f00;
background: #fff;
padding: 1em;
}
.round_shadow:after {
display: block;
content: "";
background: radial-gradient(ellipse at center, rgba(0,0,0,0.3) 0%,rgba(0,0,0,0) 66%);
z-index: -1;
position: absolute;
top: 80%;
right: 10%;
left: 10%;
bottom: -30%;
}
Obviously you can adjust the top, left, right and bottom values to position the shadow wherever you want. Also note that you may need browser-prefixes for the gradient background to work if legacy browser support is an issue.
HTML
<div class="round_shadow">
<p>De illis, cum volemus. Quod totum contra est. In schola desinis. Quis est tam dissimile homini. Respondeat totidem verbis. Tollenda est atque extrahenda radicitus.</p>
<p>Quia nec honesto quic quam honestius nec turpi turpius. Atqui reperies, inquit, in hoc quidem pertinacem; Non minor, inquit, voluptas percipitur ex vilissimis rebus quam ex pretiosissimis. Nihilo beatiorem esse Metellum quam Regulum. Illa videamus, quae a te de amicitia dicta sunt. Quantum Aristoxeni ingenium consumptum videmus in musicis? Hos contra singulos dici est melius. Aliter enim explicari, quod quaeritur, non potest. Itaque haec cum illis est dissensio, cum Peripateticis nulla sane.</p>
<p>Cum ageremus, inquit, vitae beatum et eundem supremum diem, scribebamus haec. Quam si explicavisset, non tam haesitaret. Et nunc quidem quod eam tuetur, ut de vite potissimum loquar, est id extrinsecus; Quaesita enim virtus est, non quae relinqueret naturam, sed quae tueretur.</p>
</div>
.round_shadow {
position: relative;
border-radius: 5px;
position: relative;
border: 1px solid #f00;
background: #fff;
padding: 1em;
}
.round_shadow:after {
display: block;
content: "";
background: radial-gradient(ellipse at center, rgba(0,0,0,0.3) 0%,rgba(0,0,0,0) 66%);
z-index: -1;
position: absolute;
top: 80%;
right: 10%;
left: 10%;
bottom: -30%;
}
<div class="round_shadow">
<p>De illis, cum volemus. Quod totum contra est. In schola desinis. Quis est tam dissimile homini. Respondeat totidem verbis. Tollenda est atque extrahenda radicitus.</p>
<p>Quia nec honesto quic quam honestius nec turpi turpius. Atqui reperies, inquit, in hoc quidem pertinacem; Non minor, inquit, voluptas percipitur ex vilissimis rebus quam ex pretiosissimis. Nihilo beatiorem esse Metellum quam Regulum. Illa videamus, quae a te de amicitia dicta sunt. Quantum Aristoxeni ingenium consumptum videmus in musicis? Hos contra singulos dici est melius. Aliter enim explicari, quod quaeritur, non potest. Itaque haec cum illis est dissensio, cum Peripateticis nulla sane.</p>
<p>Cum ageremus, inquit, vitae beatum et eundem supremum diem, scribebamus haec. Quam si explicavisset, non tam haesitaret. Et nunc quidem quod eam tuetur, ut de vite potissimum loquar, est id extrinsecus; Quaesita enim virtus est, non quae relinqueret naturam, sed quae tueretur.</p>
</div>
Edit
Ok, so elliptical was not not desired. To make a rectangular shadow I can think of two solutions, the primary difference between them consists in the options you have for positioning...
The first and probably simplest would be to just use a box-shadow with a negative spread (4th parameter):
.centered_shadow {
border-radius: 5px;
border: 1px solid #f00;
background: #fff;
padding: 1em;
box-shadow: 0 20px 10px -20px rgba(0,0,0,.3);
}
.centered_shadow {
border-radius: 5px;
border: 1px solid #f00;
background: #fff;
padding: 1em;
box-shadow: 0 60px 10px -40px rgba(0, 0, 0, 0.3)
}
<div class="centered_shadow">
<p>De illis, cum volemus. Quod totum contra est. In schola desinis. Quis est tam dissimile homini. Respondeat totidem verbis. Tollenda est atque extrahenda radicitus.</p>
<p>Quia nec honesto quic quam honestius nec turpi turpius. Atqui reperies, inquit, in hoc quidem pertinacem; Non minor, inquit, voluptas percipitur ex vilissimis rebus quam ex pretiosissimis. Nihilo beatiorem esse Metellum quam Regulum. Illa videamus, quae a te de amicitia dicta sunt. Quantum Aristoxeni ingenium consumptum videmus in musicis? Hos contra singulos dici est melius. Aliter enim explicari, quod quaeritur, non potest. Itaque haec cum illis est dissensio, cum Peripateticis nulla sane.</p>
<p>Cum ageremus, inquit, vitae beatum et eundem supremum diem, scribebamus haec. Quam si explicavisset, non tam haesitaret. Et nunc quidem quod eam tuetur, ut de vite potissimum loquar, est id extrinsecus; Quaesita enim virtus est, non quae relinqueret naturam, sed quae tueretur.</p>
</div>
The second method is basically the same as my suggestion for an elliptical shadow (which may give better control of the shadows position in some situations), except you give the pseudo-element a shadow instead of a gradient background, so:
.round_shadow {
border-radius: 5px;
position: relative;
border: 1px solid #f00;
background: #fff;
padding: 1em;
}
.round_shadow:after {
display: block;
content: "";
z-index: -1;
position: absolute;
top: 80%;
right: 25%;
left: 25%;
bottom: 0;
border-radius: 10px;
box-shadow: 0 30px 50px rgba(0,0,0,.3);
}
.round_shadow {
border-radius: 5px;
position: relative;
border: 1px solid #f00;
background: #fff;
padding: 1em;
}
.round_shadow:after {
display: block;
content: "";
z-index: -1;
position: absolute;
top: 80%;
right: 25%;
left: 25%;
bottom: 0;
border-radius: 10px;
box-shadow: 0 30px 50px rgba(0,0,0,.3);
}
<div class="round_shadow">
<p>De illis, cum volemus. Quod totum contra est. In schola desinis. Quis est tam dissimile homini. Respondeat totidem verbis. Tollenda est atque extrahenda radicitus.</p>
<p>Quia nec honesto quic quam honestius nec turpi turpius. Atqui reperies, inquit, in hoc quidem pertinacem; Non minor, inquit, voluptas percipitur ex vilissimis rebus quam ex pretiosissimis. Nihilo beatiorem esse Metellum quam Regulum. Illa videamus, quae a te de amicitia dicta sunt. Quantum Aristoxeni ingenium consumptum videmus in musicis? Hos contra singulos dici est melius. Aliter enim explicari, quod quaeritur, non potest. Itaque haec cum illis est dissensio, cum Peripateticis nulla sane.</p>
<p>Cum ageremus, inquit, vitae beatum et eundem supremum diem, scribebamus haec. Quam si explicavisset, non tam haesitaret. Et nunc quidem quod eam tuetur, ut de vite potissimum loquar, est id extrinsecus; Quaesita enim virtus est, non quae relinqueret naturam, sed quae tueretur.</p>
</div>
I have been struggling with placing a YouTube video within a responsive CSS column with other content. I have used the recommended fix for responsive video scaling from CSS Tricks and other places. It works fine in Firefox, but the video disappears in Chrome and Safari. I have also tried using http://fitvidsjs.com but without success. Does anyone know of a way to get videos to appear properly within a CSS column with other content? I have also tried to work with other embedded non-video content (Issuu.com publications) and had the same problem.
Here is the CSS and HTML:
#content {
margin-left: auto;
margin-right: auto;
width: 100%;
overflow: hidden;
*zoom: 1;
overflow: hidden;
position: relative;
}
#content .content-columns {
display: inline;
float: left;
margin-left: 5%;
margin-right: 5%;
width: 90%;
-moz-column-count: 3;
-webkit-column-count: 3;
column-count: 3;
-moz-column-rule: 1px solid #ECECFB;
-webkit-column-rule: 1px solid #ECECFB;
column-rule: 1px solid #ECECFB;
-moz-column-gap: 26px;
-webkit-column-gap: 26px;
column-gap: 26px;
}
.mod-embed-video{
position: relative;
padding-bottom: 56.25%;
padding-top: 35px;
height: 0;
overflow: hidden;
}
.mod-embed-video iframe, .mod-embed-video object, .mod-embed-video embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
<div id="content">
<div class="content-columns">
<p>Lorem ipsum dolor sit amet, quodsi salutandi at mel, dicam accusamus ut mel. Tation omittam singulis nec no. Ea mea ludus corpora efficiendi. Vel id nihil legendos pertinacia, prima vocibus ut usu. Omnis delicata ut sea, lorem philosophia ex eos, an elit accommodare quo.</p>
<p>Et vim vero assum error. Sumo tantas an sit, magna dicta an mel, ut wisi feugait consequat eum. An ius recteque dignissim assueverit. Ius homero populo expetenda te, an sit amet possit pertinacia. Sed aeterno perpetua ea. Eam cu ullum dicta, commodo appareat id pro.</p>
<p>Mea cu commodo aeterno labitur, ius dolorem intellegat disputando ea, cum eros harum no. Errem principes delicatissimi in vel. Evertitur forensibus eu sea, te has eirmod tractatos consetetur. Te has vitae mandamus suscipiantur, duo labores mentitum principes eu.</p>
<p>Ad elitr vocibus vim, agam oportere est et, his eu elit facilisi tacimates. Soleat torquatos deterruisset mel ut, in tollit ocurreret his, vis et nulla epicurei vituperata. Tation euismod accusam sea in, sed modo dico ut. Pri ignota putant iudicabit ex.</p>
<p>Et vim vero assum error. Sumo tantas an sit, magna dicta an mel, ut wisi feugait consequat eum. An ius recteque dignissim assueverit. Ius homero populo expetenda te, an sit amet possit pertinacia. Sed aeterno perpetua ea. Eam cu ullum dicta, commodo appareat id pro.</p>
<div class="mod-embed-video">
<iframe width="550" height="309" src="//www.youtube.com/embed/9-5MVFMWSh0?rel=0" frameborder="0" allowfullscreen></iframe>
</div>
<p>Et vim vero assum error. Sumo tantas an sit, magna dicta an mel, ut wisi feugait consequat eum. An ius recteque dignissim assueverit. Ius homero populo expetenda te, an sit amet possit pertinacia. Sed aeterno perpetua ea. Eam cu ullum dicta, commodo appareat id pro.</p>
</div>
</div>
because you use float:left and it breaks your responsive iframe approach because position is set to absolute, therefore you get nothing. You need to find another solution where either you use another approach for columns, probably using Jquery, because column-count won't work and quite honestly I can't think of any pure html5+css approach that will allow automatic columns + responsive video
I have the following problem: I have a horizontal menu with a sub-menu beneath it. I want the sub-menu to slide up under the main menu. Normally this would be no problem at all, just have the sub-menu on a lower z-index and move it up. BUT in this case both the menu and sub-menu have partial opacity. As things stand now when I move the sub-menu up you can still see it showing through the main nav.
What I need to do is as the sub-menu moves up make the part of it that's under the main menu invisible.
There's an animated gif showing the correct behavior and appearance at http://i.stack.imgur.com/1n4jJ.gif
Any ideas? Thanks!
[ADDITION]
Here's my demo code. The CSS:
body {
margin: 0;
padding: 0;
background: url('http://i.stack.imgur.com/jGlzr.png') no-repeat 0 0 scroll;
}
#topmenu {
position: fixed;
width: 100%;
height: 50px;
background-color: rgba(255,255,255,0.5);
}
#submenu {
position: relative;
width: 100%;
height: 50px;
top: 50px;
padding-top: 10px;
background-color: rgba(255,255,255,0.5);
border-top: 1px solid #666666;
}
#main {
position: relative;
top: 60px;
}
And the HTML:
<body>
<div id="topmenu">Menu 1 | Menu 2 | Menu 3 | Menu 4</div>
<div id="submenu">Sub menu 1 | Sub menu 2 | Sub menu 3 | Sub menu 4</div>
<div id="main">
<h1>Here is the main content!</h1>
<p><strong>Notice how when you scroll this page the sub menu is still visible under the main menu? I need it to be clipped as it moves under the main menu. *AND* I want to do this without JavaScript. It's OK to see the main text under the main nav.</strong></p>
<h2>Here's an animated gif that hopefully shows what I'm after...</h2>
<img src="http://i.stack.imgur.com/1n4jJ.gif" alt="sliding nav demo" />
<p>Lorem ipsum dolor sit amet, consecetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum.</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum.</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum.</p>
</div>
</body>
I've now tossed demo code up on JSFiddle at http://jsfiddle.net/chrisspurgeon/6ddWz/ . It has the correct behavior EXCEPT that the part of the sub-nav that's under the main nav should be invisible, and the translucency of the main nav should not be effected.
you must set the z-index value for both divs and,you must give the lower div a greater z-index value,also you must set the overflow of the bottom div to visible.
example:
.upperdiv {z-index:5;}
.bottomdiv {z-index:100;overflow:visible;}
This example isn't exact, but it should put you in the right direction: Updated Fiddle
HTML
<div id="header">Hover this.
<div id="drop">Drop content here</div>
</div>
CSS
#drop {
background: rgba(0, 0, 0, .5);
color: white;
height: 0;
overflow: hidden;
-webkit-transition: all .8s ease;
-moz-transition: all .8s ease;
-ms-transition: all .8s ease;
-o-transition: all .8s ease;
transition: all .8s ease;
position: absolute;
}
To hide on scroll
$(function(){
$(window).scroll(function() {
if ($(this).scrollTop() > 0) {
$("#drop").css('height', '0');
}
else {
$("#drop").css('height', '20px');
}
});
});
There are two things at work here.
1. Z-indexing
The topmenu needs to be rendered above the submenu in the stack. Right now because of simple HTML ordering, your submenu is being rendered above the topmenu.
We fix this with z-indexing:
#topmenu
{
z-index: 999;
}
#submenu
{
z-index: 998;
}
2. Opacity
In the example you provided (this GIF), the topmenu has a fully opaque background. In order to completely hide the submenu when it passes behind the topmenu, we need1 to have a fully opaque background:
#topmenu
{
background: rgba(255, 255, 255, 1);
}
JSFiddle
Footnotes:
1: This is only if you want a JS-free solution. If you will allow JS, there are solutions that will allow you to use partially transparent backgrounds.
I have a simple page.
HTML and CSS are as follows.
<body>
<div style="background-color:red;">
<div style="background-color:green; width:40%; float:left;">
LEFT
</div>
<div style="background-color:blue; width:60%; float:right;">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.
</div>
</div>
</body>
The problem is that the contents of blue div come from php and it causes variable height of blue div. What I want, is to have the height of the left green div to be same as the height of blue div.
I've solved this one using jquery but can I achieve this one only with html and css?
Thanks.
Don't float the elements, wrap the elements using a wrapper div, assign display: table; to the wrapper element, and than assign display: table-cell; to nested elements, that's all you need to achieve what you want to..
Demo
.wrap {
display: table;
width: 100%;
}
.wrap div.one, div.two {
display: table-cell;
width: 50%;
}
.wrap .one {
background: #f00;
}
.wrap .two {
background: #0f0;
}
Depending on which browsers you need to support, you could use CSS flexbox.
Simple example:
div{
display: flex;
}
Demo
CSS Flexbox browser support