Im trying to create a side left menu for mobile but I have an issue :
When I scroll my content, my header image follows the scroll and hides some content. I need my header to be fixed in it's place...
Here is a demonstration of my problem: http://jsfiddle.net/th46k/7/
My Html:
<header id="top">
<span id="logo"><img src="http://placehold.it/350x150" /></span>
</header>
<div id="menu">
<ul>
<li>Menu Item 1
</li>
<li>Menu Item 2
</li>
<li>Menu Item 3
</li>
</ul>
</div>
<div id="right">
<div id="menubar">
<div id="button">Menu</div>
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
And this is my CSS:
* {
padding: 0px;
margin: 0px;
}
#top {
width:226px;
margin:10px auto 10px auto;
}
#logo {
float:left;
}
#menubar {
width:100%;
background-color:#444;
color: #fff;
padding: 10px;
}
#button {
cursor:pointer;
}
#menu, #right {
}
#menu li a {
padding: 10px;
display: block;
color: white;
text-decoration: none;
}
#right {
width:100%;
background-color: #fff;
z-index: 5;
position: fixed;
overflow: scroll;
left: 0px;
height: 100%;
-webkit-box-shadow: -5px 0px 4px 0px rgba(0, 0, 0, 0.2);
moz-box-shadow: -5px 0px 4px 0px rgba(0, 0, 0, 0.2);
o-box-shadow: -5px 0px 4px 0px rgba(0, 0, 0, 0.2);
box-shadow: -5px 0px 4px 0px rgba(0, 0, 0, 0.2);
}
#right p {
padding: 10px;
}
#menu {
float:left;
width: 350px;
height: 100%;
}
#menu li {
background-color:#444;
border-bottom: 1px solid #888;
}
Here is an example related to your requirement. When you scroll the page the header area will stick to the top. Do some changes as per your requirement. Hope it will help you.
Demo
Related
How can I contain the text to be within the width of my div and wrap to a new line in my css? Thank you!!
.render-message {
margin-top: 8px;
height: 90px;
margin-bottom: 8px;
}
.render-message {
margin-top: 8px;
height: 90px;
margin-bottom: 8px;
border: 1px solid red;
}
<div class="render-message">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry s standard dummy text ever since the when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived
not only five centuries, but also the leap into electronic typesetting, remaining essentially
</div>
The above photo is the output of the CSS code; it was supposed to display 2 columns (#leftcolumn and #rightcolumn) with some random text inside the 2 columns respectively, but the output displayed just the #leftcolumn with the text in it alone.
Please, how do I solve it?
body {
margin: 0;
padding: 0;
line-height: 1.5em;
}
#header {
background: black;
font-family: Arial;
height: 100px;
}
#contentwrapper {
float: left;
width: 100%;
}
#contentcolumn {
margin: 0px 230px 0px 230px;
}
#leftcolumn {
float: left;
width: 230px;
margin-left: -230px;
background: #f0071b;
}
#rightcolumn {
float: left;
margin-left: -230%;
width: 230px;
background: #20e6d2;
}
.innertext {
margin: 20px;
font-family: Arial;
color: #d6a7c4;
text-align: justify;
}
#footer {
clear: left;
/* Cannot float on left */
width: 100%;
background: #000000;
color: #FFF;
font-family: Arial;
text-align: center;
padding: 4px;
}
/* Navigation Bar Begins here */
ul {
list-style-type: none;
margin: 0;
padding: 0;
background-size: #000;
}
li {
float: left;
border-right: 1px solid #bbb;
}
li:last-child {
border-right: none;
}
li a {
display: block;
color: #FFF;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover:not(.active) {
background-color: #d2f7f0;
}
.active {
background-color: #025dfa;
}
/* Responsive Css Layout */
#media (max-width: 840px) {
/* drop Right Column Drop Down */
#leftcolumn {
margin-left: -100px;
}
#rightcolumn {
float: none;
width: 100% margin-left: 0;
clear: both;
}
#contentcolumn {
margin-right: 0;
/* left margin to leftcolumnWidth */
}
}
#media (max-width: 600px) {
/* Drop left column down */
#leftcolumn {
float: none;
width: 100%;
clear: both;
margin-left: 0;
}
#contentcolumn {
margin-left: 0;
}
}
<div id="container">
<div id="header">
<ul style="display: inline;">
<li><a class="active" href="#home">Home</a></li>
<li>About</li>
<li>News</li>
<li>Contact</li>
</ul>
</div>
<div id="contentwrapper">
<div id="contentcolumn">
<div class="innertext">
<b>Welcome!</b><br />Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. <br />Why do we use it? It is a long established fact that a reader will be distracted by the readable content of a page when looking at
its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors
now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and
the like).
</div>
</div>
</div>
<div id="leftcolumn">
<div class="innertext">
<b>The left Column: <em>230px</em></b><br />Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor
at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes
from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum"
</div>
</div>
<div id="rightcolumn">
<div class="innertext">
<b>The right column:<em>230px</em></b><br />There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable.
If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first
true generator on the Internet.
</div>
</div>
<div id="footer">Footer</div>
</div>
margin-left: -230%; moves the element out of the visible area (230% to the left). Erase that and you'll see it again.
Or did you mean pixels instead of percent?
As I understood I created a design using your code. Get some Idea if you expect this way
I have used
display:flex
method, have a look
.header{
background: black;
font-family: Arial;
height: 100px;
}
.contentwrapper{
display: flex;
}
.footer{
clear: left;
width: 100%;
background: #000000;
color: #FFF;
font-family: Arial;
text-align: center;
padding: 4px;
}
.leftcolumn {
background: #f0071b;
}
.rightcolumn {
background: #20e6d2;
}
/* Navigation Bar Begins here */
ul {
list-style-type: none;
margin: 0;
padding: 0;
background-size: #000;
}
li {
float: left;
border-right: 1px solid #bbb;
}
li:last-child {
border-right: none;
}
li a {
display: block;
color: #FFF;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover:not(.active) {
background-color: #d2f7f0;
}
.active {
background-color: #025dfa;
}
<div id="container">
<div class="header">
<ul style="display: inline;">
<li><a class="active" href="#home">Home</a></li>
<li>About</li>
<li>News</li>
<li>Contact</li>
</ul>
</div>
<div class="contentwrapper">
<div class="leftcolumn">
<b>The left Column: <em>230px</em></b><br />Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor
at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes
from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum"
</div>
<div class="innertext">
<b>Welcome!</b><br />Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. <br />Why do we use it? It is a long established fact that a reader will be distracted by the readable content of a page when looking
at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page
editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour
and the like).
</div>
<div class="rightcolumn">
<b>The right column:<em>230px</em></b><br />There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable.
If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the
first true generator on the Internet.
</div>
</div>
<div class="footer">Footer</div>
</div>
I have made a tooltip on hover over an icon and it works fine in desktop view.
Working Snippet:
.tooltip {
position: relative;
display: inline-block;
}
.tooltip img {
width: 15px;
}
.tooltip .tooltiptext[data-position="bottom"] {
visibility: hidden;
width: 400px;
background-color: #fff;
color: #000;
text-align: center;
border-radius: 0.5rem;
border-width: 1px;
border-color: #e2e8f0;
padding: 5px;
position: absolute;
z-index: 1;
top: 100%;
left: 50%;
margin-left: -60px;
}
.tooltip:hover .tooltiptext {
visibility: visible;
}
<label> Some Label </label>
<span className="ml-2">
<div class="tooltip">
<img
src="https://www.svgrepo.com/show/2297/doubts-button.svg"
alt="help text"
/>
<span data-position="bottom" class="tooltiptext">
Lorem Ipsum is simply dummy text of the printing and typesetting
industry. Lorem Ipsum has been the industry's standard dummy text ever
since the 1500s, when an unknown printer took a galley of type and
scrambled it to make a type specimen book. It has survived not only five
centuries, but also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s with the release
of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions
of Lorem Ipsum.
</span>
</div>
</span>
Whereas in mobile view, this leads to horizontal scroll bar.
Please switch to mobile view to see the issue.
Things I tried:
I have tried removing margin-left and modified left value like,
.tooltip .tooltiptext[data-position="bottom"] {
visibility: hidden;
width: 400px;
.
.
.
.
.
left: 0%;
margin-left: 0px;
}
But this doesn't work... Kindly please help me to make this tooltip responsive in mobile devices using CSS. Big thanks in advance.
Just add the following css:
#media screen and (max-width: 576px) {
.tooltiptext {
width: 300px;
}
}
As the title explains, I have a little problem displaying a <hr> line.
In IE 7, 8, 9, Google Chrome, Opera Safari, all the same, no problem just one doesn't support the CSS3 effects like shadows, etc.
What I'm trying 2 do is, separate some news article by adding that line, but in Firefox that line is out of the container, is like is having position: absolute; and padding: 500px;
Here is my html markup :
<div class="container">
<div class="main-content-container">
<div class="article-container">
<div class="article-header">
<p class="article-count">0</p><p class="article-categories">1,2, 3, 4, 5</p>
<h1 class="article-title"><a href='#'>Lorem Ipsum is simply dummy</a></h1>
<p class="article-auth-date">2013 Apr 06</p>
</div> <!-- end of article-header -->
<img alt="bla bla bla" src="http:/localhost/uploads/test.png" style="border: none;">
<div class="article-post">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p></div><!-- end of article-post-->
</div>
<hr class="fancy-hr">
</div><!-- end of article-container -->
</div><!-- end of main-content-container -->
<aside></aside><!-- end of aside -->
</div><!-- end of container -->
And this is the CSS :
.main-content-container {
float:left;
margin: 5px 0 0;
padding: 0;
width: 660px;
height: 800px;
background-color: white;
-moz-box-shadow:inset 0px 0px 20px 4px rgba(173, 173, 173, 0.5);
-webkit-box-shadow:inset 0px 0px 20px 4px rgba(173, 173, 173, 0.5);
box-shadow:inset 0px 0px 20px 4px rgba(173, 173, 173, 0.5);
border: 1px solid #818080;
.article-container {
float: left;
margin: 20px;
padding: 0;
width: 615px;
}
.article-header {
float: left;
margin: 0;
padding: 5px 0 0 ;
width: 100%;
height: 50px;
margin-bottom: 20px;
}
.article-post {
border-top:1px solid #D3D3D3;
text-align:justify;
padding:3px;
margin-top:3px;
margin-bottom:5px;
font-size: 14px;
font-family: 'Lato', sans-serif;
color: #000;
}
hr.fancy-hr {
width: 100%;
border: 0;
height: 1px;
background: #c5c3c3;
-webkit-box-shadow: 2px 0px 20px rgba(50, 50, 50, 0.75);
-moz-box-shadow: 2px 0px 20px rgba(50, 50, 50, 0.75);
box-shadow: 2px 0px 20px rgba(50, 50, 50, 0.75);
}
And 2 screenshots from both Google Chrome & Firefox:
http://i1217.photobucket.com/albums/dd399/MarianStroiu/googlechrome.png Google Chrome
http://i1217.photobucket.com/albums/dd399/MarianStroiu/ff.png Firefox
hr has very little support and is not treated well in browsers. It is not used a lot in my experience. The code below is common practice for what you want, customize it how you feel -
div.line {
border-bottom:thin solid #fff;
}
<div class="container">
<div class="main-content-container">
<div class="article-container">
<div class="article-header">
<p class="article-count">0</p><p class="article-categories">1,2, 3, 4, 5</p>
<h1 class="article-title"><a href='#'>Lorem Ipsum is simply dummy</a></h1>
<p class="article-auth-date">2013 Apr 06</p>
</div> <!-- end of article-header -->
<img alt="bla bla bla" src="http:/localhost/uploads/test.png" style="border: none;">
<div class="article-post">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p></div><!-- end of article-post-->
</div>
<!--<hr class="fancy-hr">--> do not use
<div class="line"></div>
</div><!-- end of article-container -->
</div><!-- end of main-content-container -->
This is related to the foreground color, Kevin Lynch's fix did not work for me on a page with a light grey (#d1d1d1) body background.
Changing the HR colour to white does work and it now appears as etched.
hr {color: #ffffff;}
In practice the HR just needs to be any shade that is lighter than the background, so white will always work.
I'm sure this isn't ideal for you, but rather than having to worry about all that styling, why not just make it an IMAGE instead of HR? It would be much more easily maintained and could simply be included as a wide image and simplify all your CSS.
Otherwise, have you tried lowering the width of the HR? It sounds dumb, but I have encountered situations before where the width has made the HR element pop out of its div.
How to wrap one div around another? I have following two div ids:
#course {
width: 325px;
padding-right: 25px;
border-right: 1px solid #999;
border-top: 1px solid #999;
}
#home-page-sign-up {
width: 275px;
#padding-left: 25px;
float: right;
margin: auto;
#position: relative;
display: block;
clear: both;
}
I want #course to be on left and #home-page-sign-up on right just next to it. I do get block on left and right as assigned but one is below another, I want them to be side by side.
How can I achieve it?
You will want to float both of them left:
#course{
float:left;
width:325px;
padding-right:25px;
border-right:1px solid #999;
border-top:1px solid #999;
}
#home-page-sign-up {
width:275px;
#padding-left:25px;
float:left;
margin: auto;
#position:relative;
display:block;
}
Just make sure #course falls first in the html
Try this:
#course{
width:325px;
float:left;
padding-right:25px;
border-right:1px solid #999;
border-top:1px solid #999;
}
#home-page-sign-up {
width:275px;
#padding-left:25px;
float:left;
margin: auto;
#position:relative;
}
Then, in your body tags, do:
<div id="course">Course Div Content here...</div>
<div id="home-page-sign-up">Home Sign-up Content here...</div>
<div style="clear: left;"></div>
That's one way...that hopefully works ;)
I dont know what you mean by "wrap around" but if you want the divs to be next to each other, put float: left; in both styles...
see fiddle for code and demo
Fiddle: http://jsfiddle.net/t4LUF/3/
Demo: http://jsfiddle.net/t4LUF/3/embedded/result/
NOTE: For demo purpose i gave border to all div's you can change as per your need.
HTML:
<div id="big-container">big-container
<div id="container">
<div id="course">course Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>
<div id="home-page-sign-up">home-page-sign-up </div>
</div>
</div>
SS: http://img812.imageshack.us/img812/3783/divcontainersidebyside.jpg