Navigation overlaps elements when wrapping - html

I have a bunch of inline-blocks which I want to wrap when the browser window is shrunken. They look like this:
[nav element 1] [nav element 2] [nav element 3] [nav element 4]
This is a {h1} header.
When the browser is resized, I want them to wrap, which they do. But they overwrite the header on the next line:
[nav element 1] [nav element 2] [nav element 3]
[nav element 4]eader.
I've tried separating the header with paragraphs and linebreaks. Nope.
I've tried putting a "clear:both" on the {h1} style. Nope.
I've tried putting a {div} around the {h1} with a "display:block" and/or a "clear:both". Nope.
I want the page content to move down when the nav bar wraps.
Any hints?
My code and its results can be seen at criv.com/test
EDIT
body {
margin-left: auto;
margin-right: auto;
width: 80%;
background-color: #FFFFFF;
}
h1 {
display:inline-block;
background:#FF0000;
border:2px solid black;
clear:both;
}
.nav {
display: block;
position: absolute;
top: -1px;
float: left;
overflow: auto;
}
.nav a {
display:inline-block;
width:88px;
height:50px;
font-family:"Comic Sans MS", Arial, Sans-serif;
color:#FFFFFF;
background-color:#008000;
text-align:center;
padding:0px;
margin:0px;
border-style:solid;
border-color:#FFFFFF;
border-width:1px;
text-decoration:none;
}
.nav a:visited {
color:#CCCCCC;
}
.nav a:hover, a:active {
color:#008000;
background-color:#CCCCCC;
}
.nav a#here {
color:#008000;
background-color:white;
}
ul.subnav {
background-color:#009000;
padding:0px;
margin:0px;
border:1px solid #009000;
width:618px;
height:18px;
position:absolute;
top:72px;
left:220px;
}
ul.subnav li {
display:block;
width:123px;
height:18px;
background-color:#009000;
list-style-type:none;
margin:0px;
padding:0px;
border-width:0px;
overflow:hidden;
float:left;
}
ul.subnav a {
display:block;
width:123px;
height:18px;
font-family:"Comic Sans MS", Arial, Sans-serif;
font-size:75%;
font-weight:bold;
color:#FFFFFF;
background-color:#009000;
text-align:center;
padding:0px;
border-width:0px;
margin:0px;
text-decoration:none;
}
ul.subnav a:visited {
color:#CCCCCC;
}
ul.subnav a:hover, a:active {
color:#008000;
background-color:#CCCCCC;
}
ul.subnav a#here {
color:#008000;
background-color:white;
}
.note {
background-color:#7A991A;
}
.text {
background-color:white;
font-family:"Comic Sans MS", Arial, Sans-serif;
color:#008000;
width:80%;
left:10%;
}
.text a:link {
color:#008000;
}
.text a:visited {
color:#999999;
}
<div class="nav">
2014 peony list
bloom calendar
photo gallery
peony<br />how-to's
peony<br />tales
<br />visit
<span class="clearfix">contact/ order</span>
</div>
<br />
<div class="notreally"><h1>peonies of the coos riviera</h1></div>
<span class="text">
Just above the Connecticut River in New Hampshire's Coos County,
more than a hundred varieties of herbaceous peonies, tree peonies,
and intersectional-hybrid peonies bloom from late May to early July.
<p>The display garden has closed for the season. To order peonies for fall planting,
email peonies#criv.com, or phone 603.837.9800.</p>
<p>Review <b>the 2014 bloom season</b> in pictures!</p>
</span>

Remove position absolute from it. If you want nav to push 1px to top then you can use margin-top:-1px
Here is working code.
body {
margin-left: auto;
margin-right: auto;
width: 80%;
background-color: #FFFFFF;
}
h1 {
display:inline-block;
background:#FF0000;
border:2px solid black;
clear:both;
}
.nav {
display: block;
float: left;
overflow: auto;
}
.nav a {
display:inline-block;
width:88px;
height:50px;
font-family:"Comic Sans MS", Arial, Sans-serif;
color:#FFFFFF;
background-color:#008000;
text-align:center;
padding:0px;
margin:0px;
border-style:solid;
border-color:#FFFFFF;
border-width:1px;
text-decoration:none;
}
.nav a:visited {
color:#CCCCCC;
}
.nav a:hover, a:active {
color:#008000;
background-color:#CCCCCC;
}
.nav a#here {
color:#008000;
background-color:white;
}
ul.subnav {
background-color:#009000;
padding:0px;
margin:0px;
border:1px solid #009000;
width:618px;
height:18px;
position:absolute;
top:72px;
left:220px;
}
ul.subnav li {
display:block;
width:123px;
height:18px;
background-color:#009000;
list-style-type:none;
margin:0px;
padding:0px;
border-width:0px;
overflow:hidden;
float:left;
}
ul.subnav a {
display:block;
width:123px;
height:18px;
font-family:"Comic Sans MS", Arial, Sans-serif;
font-size:75%;
font-weight:bold;
color:#FFFFFF;
background-color:#009000;
text-align:center;
padding:0px;
border-width:0px;
margin:0px;
text-decoration:none;
}
ul.subnav a:visited {
color:#CCCCCC;
}
ul.subnav a:hover, a:active {
color:#008000;
background-color:#CCCCCC;
}
ul.subnav a#here {
color:#008000;
background-color:white;
}
.note {
background-color:#7A991A;
}
.text {
background-color:white;
font-family:"Comic Sans MS", Arial, Sans-serif;
color:#008000;
width:80%;
left:10%;
}
.text a:link {
color:#008000;
}
.text a:visited {
color:#999999;
}
<div class="nav">
2014 peony list
bloom calendar
photo gallery
peony<br />how-to's
peony<br />tales
<br />visit
<span class="clearfix">contact/ order</span>
</div>
<br />
<div class="notreally"><h1>peonies of the coos riviera</h1></div>
<span class="text">
Just above the Connecticut River in New Hampshire's Coos County,
more than a hundred varieties of herbaceous peonies, tree peonies,
and intersectional-hybrid peonies bloom from late May to early July.
<p>The display garden has closed for the season. To order peonies for fall planting,
email peonies#criv.com, or phone 603.837.9800.</p>
<p>Review <b>the 2014 bloom season</b> in pictures!</p>
</span>

Related

Drop menu misbehaving. Possibly z-index?

I have two drop menus. the "choose a state" menu and "select a carrier" menu. Here's the thing: I want my drop menus to behave like my "state" menu, in that it moves content below it downwards. However, I want them to look like my "carrier" menu, in that it looks like two separate menus when you click on it. Here is my fiddle for code reference: http://jsfiddle.net/SteveSerrano/rc7fhhhu/
Note: The only difference between the two menus is that "state" is positioned "relative" with a z-index of 9999. "carrier" is positioned "absolute" with a z-index of 9999. I'm lost. Need any help. Thanks :)
<div class="state_box">
<input type="checkbox" id="state-tgl" onblur="closeMenu(this)">
<label id="state-tgl-label" for="state-tgl">
<span class="collapse_tiny">Choose a state</span>
<span class="collapse expand_tiny inline">State</span>
<img src="/images/template2014/dropdown-black.svg" style="vertical-align:middle; width:10px;">
</label>
<ul id="state_drop-menu">
<li><span class="collapse_tiny">Connecticut</span></li>
<li><span class="collapse_tiny">New Hampshire</span></li>
<li><span class="collapse_tiny">New Jersey</span></li>
<li><span class="collapse_tiny">New York</span></li>
</ul>
<div class="carrier_box">
<input type="checkbox" id="carrier-tgl" onblur="closeMenu(this)">
<label id="carrier-tgl-label" for="carrier-tgl">
<span class="collapse_tiny">Select a carrier</span>
<span class="collapse expand_tiny inline">State</span>
<img src="/images/template2014/dropdown-black.svg" style="vertical-align:middle; width:10px;">
</label>
<ul id="carrier_drop-menu">
<li><span class="collapse_tiny">Carrier 1</span><span class="collapse expand_tiny inline">Conn.</span></li>
<li><span class="collapse_tiny">Carrier 2</span><span class="collapse expand_tiny inline">N.H.</span></li>
<li><span class="collapse_tiny">Carrier 3</span><span class="collapse expand_tiny inline">N.J.</span></li>
<li><span class="collapse_tiny">Carrier 4</span><span class="collapse expand_tiny inline">N.Y</span></li>
</ul>
CSS CODE:
.state_box{
margin-bottom:-9px;
background-color:rgba(6, 0, 0, 0.09);
padding-left:10px;
padding-right:10px;
padding-bottom:7px;
padding-top:15px;
width:160px;
}
.state_box ul{
margin:0;
padding:0;
list-style-type: none;
}
.state_box ul li{
display:inline;
}
.state_box ul ul{
display:inline;
}
.state_box ul li a{
text-decoration:none;
padding-left:16px;
color:#000;
font-family:'Raleway', Arial, Helvetica, sans-serif;
font-weight:500;
font-size:23px; font-size:2.3rem;
text-transform:uppercase;
vertical-align:-8px;
color:#939598;
}
.state_box ul li a.first_state{
padding-left:0px;
}
.state_box ul li .third_level{
color:#a7a9ac;
font-size:18px; font-size:1.8rem;
vertical-align:-5px;
}
.state_box ul li .fourth_level{
color:#BCBEC0;
font-size:14px; font-size:1.4rem;
vertical-align:-3px;
}
.state_box ul li a:hover{
color:#808285;
}
.state_box ul li .selected_state{
font-size:36px; font-size:3.6rem
color:#000000;
text-transform:uppercase;
vertical-align:text-top;
color:#000;
font-family:'Raleway', Arial, Helvetica, sans-serif;
}
#state-tgl{
position:absolute;
/* IE 8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
/* Real Browsers */
opacity:0;
}
#state-tgl-label{
font-size:28px; font-size:1.8rem;
color:#000000;
font-family:'Raleway', Arial, Helvetica, sans-serif;
/*font-weight:500;*/
display:block;
}
#state-tgl-label img{
float:right;
margin-top:5px;
}
#state_drop-menu{
position:relative;
z-index:9999;
background-color:rgba(6, 0, 0, 0.09);
/*border:solid 2px black;*/
width:200px;
padding-top:8px;
padding-bottom:8px;
display:none;
max-height:0px;
transition: max-height 0.25s ease;
margin-left:-10px;
margin-top:10px;
}
#state_drop-menu li{
display:block;
padding:0px;
margin:0px;
width:100%;
}
#state_drop-menu li a{
font-size:36px; font-size:1.8rem;
color:black;
padding:0px;
margin:0px;
display:block;
padding-left:8px;
padding-right:8px;
}
#state_drop-menu li a:hover{
color:white;
background-color:black;
}
#state-tgl:checked ~ #state_drop-menu{
display:block;
max-height:1000px;
}
/*########### Carrier Drop Menu ############*/
.carrier_box{
margin-bottom:-9px;
background-color:rgba(6, 0, 0, 0.09);
padding-left:10px;
padding-right:10px;
padding-bottom:7px;
padding-top:15px;
width:320px;
}
.carrier_box ul{
margin:0;
padding:0;
list-style-type: none;
}
.carrier_box ul li{
display:inline;
}
.carrier_box ul ul{
display:inline;
}
.carrier_box ul li a{
text-decoration:none;
padding-left:16px;
color:#000;
font-family:'Raleway', Arial, Helvetica, sans-serif;
font-weight:500;
font-size:23px; font-size:2.3rem;
text-transform:uppercase;
vertical-align:-8px;
color:#939598;
}
.carrier_box ul li a.first_carrier{
padding-left:0px;
}
.carrier_box ul li .third_level{
color:#a7a9ac;
font-size:18px; font-size:1.8rem;
vertical-align:-5px;
}
.carrier_box ul li .fourth_level{
color:#BCBEC0;
font-size:14px; font-size:1.4rem;
vertical-align:-3px;
}
.carrier_box ul li a:hover{
color:#808285;
}
.carrier_box ul li .selected_carrier{
font-size:36px; font-size:3.6rem
color:#000000;
text-transform:uppercase;
vertical-align:text-top;
color:#000;
font-family:'Raleway', Arial, Helvetica, sans-serif;
}
#carrier-tgl{
position:absolute;
/* IE 8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
/* Real Browsers */
opacity:0;
}
#carrier-tgl-label{
font-size:28px; font-size:1.8rem;
color:#000000;
font-family:'Raleway', Arial, Helvetica, sans-serif;
/*font-weight:500;*/
display:block;
}
#carrier-tgl-label img{
float:right;
margin-top:5px;
}
#carrier_drop-menu{
position:absolute;
z-index:9999;
background-color:rgba(6, 0, 0, 0.09);
/*border:solid 2px black;*/
width:320px;
padding-top:8px;
padding-bottom:8px;
display:none;
max-height:0px;
transition: max-height 0.25s ease;
margin-left:-10px;
margin-top:10px;
}
#carrier_drop-menu li{
display:block;
padding:0px;
margin:0px;
width:100%;
}
#carrier_drop-menu li a{
font-size:36px; font-size:1.8rem;
color:black;
padding:0px;
margin:0px;
display:block;
padding-left:8px;
padding-right:8px;
}
#carrier_drop-menu li a:hover{
color:white;
background-color:black;
}
#carrier-tgl:checked ~ #carrier_drop-menu{
display:block;
max-height:1000px;
}
#charts{
margin-top:50px;
}
This should be a good start: move your background-color from .state-box and move it onto:
#state-tgl-label {
background-color:rgba(6, 0, 0, 0.09);
}
That way only the label gets the background color, and not the whole surrounding div. The reason you need to keep position: relative is that using position: absolute takes it out of the flow of the document, which prevents your desired effect of moving the other elements of the page down when opened.
Here's a quick fiddle: http://jsfiddle.net/rc7fhhhu/1/
updated fiddle: http://jsfiddle.net/rc7fhhhu/2/
I've removed margin-left: -10px from the ul element, and moved the padding onto the #state-tgl-label element. Should be pretty close to what you were looking for.

Navigation bar buttons won't stay in parent

I'm trying to make a navigation bar for my website, but the 'info' button will not stay inside the parent. Here is my HTML:
<div id="header">
<div id="homeB">
HOME
</div>
<div id="infoB">
INFO
</div>
</div>
<div id="main"></div>
And my CSS:
#header {
height:11%;
width:70%;
background:violet;
margin-left:15%;
}
#main {
height:100%;
width:70%;
background:blue;
margin-top:1%;
margin-left:15%;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
display:inline-block;
}
#homeB {
width:20%;
height:100%;
background:red;
}
#homeBTEXT {
display:block;
font-size:250%;
text-align:center;
text-decoration:none;
font-family:Impact, charcoal, sans-serif;
color:blue;
}
#infoB {
width:20%;
height:50px;
background:red;
float:right;
left:64.2%;
}
#infoBTEXT {
display:block;
font-size:250%;
text-align:center;
text-decoration:none;
font-family:Impact, charcoal, sans-serif;
color:blue;
}
Could someone clear up why this is not working?
Thanks, I'm not great at a lot of HTML and CSS elements, so any extra help would be appreciated too :)
Give float: left; to the #homeBTEXT and also clear the #header!
#homeBTEXT {
display:block;
font-size:250%;
text-align:center;
text-decoration:none;
font-family:Impact, charcoal, sans-serif;
color:blue;
float:left;
}
#header {overflow: hidden;}
Preview
Fiddle: http://jsbin.com/setipusabihu/1

How to do this navigation bar?

i want to make a navigation bar similar the one found here.
I tried but I couldn't :D
Here's what I did:
HTML:
<ul>
<li>Home</li>
<li>News</li>
<li>Contact</li>
<li>About</li>
</ul>
CSS
ul
{
list-style-type:none;
margin:0;
padding:0;
overflow:hidden;
}
li
{
float:left;
}
a:link,a:visited
{
display:block;
width:120px;
font-weight:bold;
color:#FFFFFF;
background-color:#98bf21;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;
}
a:hover,a:active
{
background-color:#7A991A;
}
or you can try the fiddle that i created
http://jsfiddle.net/uYd9u/
I believe this is what you are looking to do.
http://jsfiddle.net/cornelas/uYd9u/11/
In order to achieve what you are wanting to create.
ul
{
list-style-type:none;
margin:0;
padding:0;
overflow:hidden;
border-bottom: 4px solid #98bf21;
text-align: right; //ADD
}
li
{
display: inline-block; //REMOVE FLOAT:right;
vertical-align: bottom; //ADD to align to bottom
}
a:link,a:visited
{
display:block;
width:120px;
font-weight:bold;
color:#98bf21;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;
}
li.active,li.active a:link{//ADD so you can have one box have a background.
background-color:#98bf21;
color:#FFFFFF;
}
a:hover,a:active
{
background-color:#7A991A;
}

how to get my navigation button stay active

Can't get my navigation to stay active using html and css. It just light up but does not stay active when pressed. What am I missing?
How do I make it stay active when pressed? Really need the help fast! Sorry for my bad code, I'm new to coding.
How do I type the active class? I tried to, but it did not work.
HTML
<div id="apaknavig">
<div id="menu2">
<ul>
<li>Uzņēmums</li>
<li>kontakti</li>
</ul>
</div>
</div>
CSS
#apaknavig {
Width: 200px;
height: 604px;
top:-613px;
position:relative;
font:14px Arial;
color:black;
float:left;
right:35px;
text-indent:12px;
display: block;
line-height:30px;
}
#menu2 ul{
list-style:none;
float: left;
font:14px Arial;
color:black;
right:90px;
text-decoration:none;
text-align:left; width:10px;
display: block;
line-height:30px;
margin-bottom:10px;
}
#menu2 a{
background-image: url(bildes/apak_navig.png);
display:block;
width: 196px;
height:34px;
font:14px Arial;
color:black;
float:left;
right:90px;
text-decoration:none;
display: block;
line-height:30px;
margin-bottom:3px;
}
#menu2 a:hover{
background-image: url(bildes/apak_navig_green.png);
color:white;
font:14px Arial;
color:black;
text-decoration:none;
display: block;
line-height:30px;
}
Just change #menu2 a:hover{ to #menu2 a:hover, #menu2 a:active {.
You just have to add #menu2 a:active to the CSS.
#menu2 a:hover,#menu2 a:active{
background-image: url(bildes/apak_navig_green.png);
color:white;
font:14px Arial;
color:black;
text-decoration:none;
display: block;
line-height:30px;
}
I tried it but it just does not work. It continues to just hover, but does not stay active when I press it.

CSS using images to replace horizontal menu links but disappears in IE7

After a long time of trying things I still not have come any closer, I do not know how to make the menu for this website (found here) I have appear in IE7.
I am using a css image replacement technique to achieve this result, currently I have a html menu with links and am replacing the links with images in css.
Could you please help me out thank you.
Here is the CSS
'#charset "utf-8";
/* CSS Reset */
/***** main styles ******/
body {
background-image:url(images/bg-top.jpg);
background-position:top center;
background-repeat:no-repeat;
background-color:#222121;
}
hr {
border : 0;
height : 2px;
background: url(images/line.png) 0 0 repeat-x;
margin : 1em 0;
}
p, h1, h2, h3, li {
font-family:Arial, Helvetica, sans-serif;
color:#b1b0b0;
}
h2 {
margin-bottom:40px;
}
h3 {
margin-top:30px;
margin-bottom:20px;
font-size:138.5%;
color:#fafafa;
text-transform:uppercase;
}
.body_text {
line-height:1.6em;
font-family: 'Arial Narrow', sans-serif;
font-size:114%;
}
input {
display:block;
border-top:2px solid #171717;
border-left:2px solid #171717;
border-right:2px solid #999;
border-bottom:2px solid #999;
background-color:#333;
width:200px;
margin-top:7px;
margin-bottom:10px;
}
textarea {
display:block;
border-top:2px solid #171717;
border-left:2px solid #171717;
border-right:2px solid #999;
border-bottom:2px solid #999;
background-color:#333;
width:300px;
height:120px;
margin-top:7px;
color:#CCC;
}
label {
color:#b1b0b0;
}
#submit {
width:100px;
border-top:2px solid #171717;
border-left:2px solid #171717;
border-right:2px solid #171717;
border-bottom:2px solid #171717;
color:#FFF;
}
/*** header styles ********/
#header_container {
margin:30px auto 0px auto;
width:860px;
height:110px;
background-image:url(images/line.png);
background-repeat:repeat-x;
background-position:0px 88px;
}
#menu {
position:relative;
left:527px;
top:-8px;
}
#menu li {
display:inline;
margin-right:20px;
}
#menu li.last {
display:inline;
margin-right:0px;
}
.menu_link1:link, .menu_link1:visited {
display:inline-block;
text-indent:-3000px;
width:45px;
height:16px;
background-image:url(images/home.png);
}
.menu_link1:active, .menu_link1:hover {
background-image:url(images/home_highlight.png);
}
.menu_link2:link, .menu_link2:visited {
display:inline-block;
text-indent:-3000px;
width:92px;
height:16px;
background-image:url(images/portfolio.png);
}
.menu_link2:hover, .menu_link2:active {
background-image:url(images/portfolio_highlight.png);
}
.menu_link3:link, .menu_link3:visited {
display:inline-block;
text-indent:-3000px;
width:45px;
height:16px;
background-image:url(images/blog.png);
}
.menu_link3:hover, .menu_link3:active {
background-image:url(images/blog_highlight.png);
}
.menu_link4:link, .menu_link4:visited {
display:inline-block;
text-indent:-3000px;
width:78px;
height:16px;
background-image:url(images/contact.png);
}
.menu_link4:active, .menu_link4:hover {
background-image:url(images/contact_highlight.png);
}
.active1 {
display:inline-block;
text-indent:-3000px;
width:45px;
height:16px;
background-image:url(images/home_highlight.png);
}
.active2 {
display:inline-block;
text-indent:-3000px;
width:92px;
height:16px;
background-image:url(images/portfolio_highlight.png);
}
.active3 {
display:inline-block;
text-indent:-3000px;
width:45px;
height:16px;
background-image:url(images/blog_highlight.png);
}
.active4 {
display:inline-block;
text-indent:-3000px;
width:78px;
height:16px;
background-image:url(images/contact_highlight.png);
}`
EDIT
Fixed the problem by adding font-size: 0px;
line-height: 0px; to the list-item.
But the background image is not centered and this only effects IE7
After looking through the menu with IE8's compatibility mode and its developer tools, there is an error with text-indent: -3000px; I have no idea what it is, but removing this makes your menu display as intended.