Grid system can't locate with navbar - css

I have some question with navbar and grid system.
Q1.grid system
I make two 100% height navbar on left and right , but the center text seems locate on the left :0 ,and the left navbar overlaps it.
Here's a link to my code.
enter link description here
html, body {
height: 100%;
width: 100%;
margin: 0;
}
[class*="col-"] {
float: left;
}
.col-1 {
width: 4.16%;
}
.col-2 {
width: 8.33%;
}
.col-3 {
width: 12.5%;
}
.col-4 {
width: 16.66%;
}
.col-5 {
width: 20.83%;
}
.col-6 {
width: 25%;
}
.col-7 {
width: 29.16;
}
.col-8 {
width: 33.33%;
}
.col-9 {
width: 37.5%;
}
.col-10 {
width: 41.66%;
}
.col-11 {
width: 45.83%;
}
.col-12 {
width: 50%;
}
.col-13 {
width: 54.16%;
}
.col-14 {
width: 58.33%;
}
.col-15 {
width: 62.5%;
}
.col-16 {
width: 66.66%;
}
.col-17 {
width: 70.83%;
}
.col-18 {
width: 75%;
}
.col-19 {
width: 79.16%;
}
.col-20 {
width: 83.33%;
}
.col-21 {
width: 87.5%;
}
.col-22 {
width: 91.66%;
}
.col-23 {
width: 95.83%;
}
.col-24 {
width: 100%;
}
.navbar-fixed-top {
position: fixed;
top: 0;
border-radius: 0;
right: 0;
left: 0;
padding-left: 0;
padding-right: 0;
z-index: 1030;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: auto;
background-color: #1c2333;
clear: both;
}
li {
float: left;
border: 1 white dashed;
line-height: 50px;
}
li:last-child {
border-right: none;
}
li a {
height: 57px;
width: 60px;
display: block;
color: #8fa5be;
text-align: center;
padding: 10px 10px;
text-decoration: none;
border-radius: 0;
overflow: visible;
border-style: solid transparent;
cursor: pointer;
}
.active, li a:hover {
color: #ffffff;
background-color: #3099f5;
}
/*--*/
.nv{
position:fixed;
display: flex;
width:4.16%;
height: 100%;
}
.nvr {
display: flex;
position: fixed;
height: 100%;
width: 80px;
border: none;
border-radius: 0;
margin: 0;
}
.height-100 {
height: 100%;
}
<div class="row navbar-fixed-top">
<div class="row">
<div class="col-24">
<ul>
<li><a class="active">Home</a></li>
<li>News</li>
<li>Contact</li>
<li style="float:right"><a class="active" href="#about">hom</a></li>
</ul>
</div>
</div>
<div class="row">
<div class="col-1">
<!--
<div class="nv height-100">
<ul>
<li><a>hom</a></li>
<li><a class="active" href="#home">hom</a></li>
</ul>
</div>
-->
<div class="nv">
<ul>
<li>Left</li>
<li>News</li>
<li>Cont</li>
<li>About</li>
</ul>
</div>
</div>
<div class="col-22">
whatever ,here just the testing text.
</div>
<!--
<div>
<ul>
<li>Home</li>
<li>News</li>
<li>Contact</li>
<li>About</li>
</ul>
</div>
-->
<div class="col-1">
<div class="nv">
<ul>
<li>Right</li>
<li>News</li>
<li>Cont</li>
<li>About</li>
</ul>
</div>
</div>
</div>
The picture shows what I want .
What I actually want .
Q2.
How can I make the same text block size with top and both side ?
At the full screen , they have the same size , but I want to know how to do.
Thank you very much.

Related

Block hover higher another block

In yellow square I have a hover effect, but when hover display the higher the green block. I need what would be the hover effect of only at yellow square.
I tried to use z-index - did not help.
What am I doing wrong?
*{
padding: 0;
margin: 0;
}
.wrapper {
border:2px solid black;
margin-top: 20px;
padding: 20px 20px;
height: 100%;
}
.block__one {
background-color:green;
z-index:5;
position: relative;
}
.item {
padding: 10px;
margin: 0;
text-align:center;
}
.list {
display: inline-block;
width: 50px;
height: 40px;
background-color:yellow;
position: relative;
z-index:10;
}
.list:hover .list__hover {
opacity:1;
bottom:0;
}
.list__hover {
width: 100%;
height: 50%;
background-color: #fff;
position: absolute;
bottom:-50px;
transition: bottom 0.5s;
opacity:0;
z-index:4;
}
.block__two {
background-color:red;
width: 100%;
height: 200px;
z-index:5;
position: relative;
}
<div class="wrapper">
<div class="block__one">
<ul class="item">
<li class="list">
<div class="list__hover"></div>
</li>
<li class="list">
<div class="list__hover"></div>
</ul>
</div>
<div class="block__two"></div>
</div>
I'm not certain I've 100% understood your post, but I believe that all you need is to add
overflow:hidden
to the .list class
Check if the snippet is doing what you want:
*{
padding: 0;
margin: 0;
}
.wrapper {
border:2px solid black;
margin-top: 20px;
padding: 20px 20px;
height: 100%;
}
.block__one {
background-color:green;
z-index:5;
position: relative;
}
.item {
padding: 10px;
margin: 0;
text-align:center;
}
.list {
display: inline-block;
width: 50px;
height: 40px;
background-color:yellow;
position: relative;
z-index:10;
overflow:hidden;
}
.list:hover .list__hover {
opacity:1;
bottom:0;
}
.list__hover {
width: 100%;
height: 50%;
background-color: #fff;
position: absolute;
bottom:-50px;
transition: bottom 0.5s;
opacity:0;
z-index:4;
}
.block__two {
background-color:red;
width: 100%;
height: 200px;
z-index:5;
position: relative;
}
<div class="wrapper">
<div class="block__one">
<ul class="item">
<li class="list">
<div class="list__hover"></div>
</li>
<li class="list">
<div class="list__hover"></div>
</ul>
</div>
<div class="block__two"></div>
</div>
Here's another solution using first height of 0% and then transitioning it to 50%. Also check your code, there's a few mistakes in it. You could, for example, use W3 validator.
* {
padding: 0;
margin: 0;
}
.wrapper {
border: 2px solid black;
margin-top: 20px;
padding: 20px 20px;
height: 100%;
}
.block__one {
background-color: green;
z-index: 5;
position: relative;
}
.item {
padding: 10px;
margin: 0;
text-align: center;
}
.list {
display: inline-block;
width: 50px;
height: 40px;
background-color: yellow;
position: relative;
z-index: 10;
}
.list:hover .list__hover {
opacity: 1;
bottom: 0px;
height: 50%;
transition: linear .5s;
}
.list__hover {
width: 100%;
height: 0%;
background-color: #fff;
position: absolute;
bottom: 0px;
opacity: 0;
z-index: 4;
}
.block__two {
background-color: red;
width: 100%;
height: 200px;
z-index: 5;
position: relative;
}
<div class="wrapper">
<div class="block__one">
<ul class="item">
<li class="list">
<div class="list__hover"></div>
</li>
<li class="list">
<div class="list__hover"></div>
</li>
</ul>
</div>
<div class="block__two"></div>
</div>

Why doesn't menu on drop down appear over content?

I've got a drop down menu that won't appear over the rest of the content. I've set the position to absolute and the z-index to 99 and no luck. Any ideas how to get it to lay on top of the rest of the site?
<body>
<header>
<div class="container">
<h1 class="logo">Relaxr</h1>
<nav>
</span>
<ul>
<li>Home</li>
<li>About</li>
<li>Contact</li>
<li>Blog</li>
</ul>
</nav>
</div>
</header>
<section id="main">
<div class="container">
nav {
position: relative;
}
nav ul {
display: none;
}
header {
margin-left: -20px;
margin-right: -20px;
}
body {
margin-left: 20px;
margin-right: 20px;
}
.container {
width: 100%;
margin: 0;
}
#main {
margin-top: 10px;
}
header nav ul li {
display: block;
margin-right: 20px;
margin: 0 20px 0 0;
}
.hamburger {
margin-top: 5px;
margin-right: 80px;
margin-bottom: 20px;
float:right;
position: relative;
display: inline-block;
width: 1.5em;
height: 0.74em;
border-top: 0.2em solid #fff;
border-bottom: 0.2em solid #fff;
}
.hamburger:before {
content: "";
position: absolute;
top: 0.9em;
left: 0px;
width: 100%;
border-top: 0.2em solid #fff;
}
nav ul {
position: absolute;
left: 0; top: 100%;
width: 100%;
background-color: black;
z-index: 99;
Codepen:
http://codepen.io/kiddigit/pen/wWvPJm
In your #media query change
nav {
position: relative;
}
to
nav {
position: absolute;
}
This will keep your menu on top.
I think You should use something like this to work
$(".hamburger").click(function(e){
$("nav > ul").toggle();
});
there is only one difference I've added a closing bracket in
$("nav > ul").toggle();

Child list disappears when hovered over it

I have a Horizontal Menu. When the mouse is hovered over the child elements it disappears. The child elements cannot be clicked. I would like the child elements to stay when the mouse is hovered over it.
.header {
color: #FFFFFF;
height: 60px;
width: 100%;
margin: auto;
}
.header_logo {
width: 40%;
height: 100%;
float: left;
}
#logo {
height: 100%;
top: 0;
left: 0;
width: 50%;
}
.header_title {
width: 60%;
float: left;
}
#titles {
position: absolute;
top: 20px;
font-family: "Times New Roman", Times, serif, Georgia;
font-size: 97%;
color: #B8B8B8;
}
ul {
list-style-type: none;
}
li {
display: inline-block;
}
a {
text-decoration: none;
color: inherit;
padding: 21px 10px;
}
li a:hover {
background-color: #666699;
}
ul li ul {
display: none;
}
ul li:hover ul {
display: block;
position: absolute;
width: 100%;
top: 70px;
left: 0;
white-space: nowrap;
}
* {
border: 0;
margin: 0;
padding: 0;
}
.content {
height: 800px;
margin: auto;
background-color: #C0C0C0;
}
.footer {
margin: auto;
background-color: #000000;
}
<div class="header">
<div class="header_logo">
<img id="logo" src="civic-logo.jpg">
</div>
<div class="header_title">
<div id="titles">
<ul>
<li>PRODUCTS
<ul>
<li>CEMENT</li>
<li>STEEL</li>
<li>BRICKS</li>
<li>SAND</li>
</ul>
</li>
<li>CONTACT US </li>
</ul>
</div>
</div>
</div>
<div class="content">
</div>
<div class="footer">
</div>
It's because you have positioned your submenu absolutely, and it's too far away from your parent li, so your mouse is leaving the parent menu before it reaches the submenu. I've added borders to show you.
.header {
color: #FFFFFF;
height: 60px;
width: 100%;
margin: auto;
}
.header_logo {
width: 40%;
height: 100%;
float: left;
}
#logo {
height: 100%;
top: 0;
left: 0;
width: 50%;
}
.header_title {
width: 60%;
float: left;
}
#titles {
position: absolute;
top: 20px;
font-family: "Times New Roman", Times, serif, Georgia;
font-size: 97%;
color: #B8B8B8;
}
ul {
list-style-type: none;
}
li {
display: inline-block;
border: 1px solid blue;
}
a {
text-decoration: none;
color: inherit;
padding: 21px 10px;
}
li a:hover {
background-color: #666699;
}
ul li ul {
display: none;
}
ul li:hover ul {
display: block;
position: absolute;
width: 100%;
top: 70px;
left: 0;
white-space: nowrap;
}
* {
border: 0;
margin: 0;
padding: 0;
}
.content {
height: 800px;
margin: auto;
background-color: #C0C0C0;
}
.footer {
margin: auto;
background-color: #000000;
}
<div class="header">
<div class="header_logo">
<img id="logo" src="civic-logo.jpg">
</div>
<div class="header_title">
<div id="titles">
<ul>
<li>PRODUCTS
<ul>
<li>CEMENT</li>
<li>STEEL</li>
<li>BRICKS</li>
<li>SAND</li>
</ul>
</li>
<li>CONTACT US </li>
</ul>
</div>
</div>
</div>
<div class="content">
</div>
<div class="footer">
</div>
You have padding, but it's on your a element, and needs to be on your li element, instead. Either add padding-top to your submenu li elements or adjust their top position so that they're directly underneath (aka "touching") the parent element.
Here is the code with the menu moved to top: 40px and the padding added to the submenu li elements:
.header {
color: #FFFFFF;
height: 60px;
width: 100%;
margin: auto;
}
.header_logo {
width: 40%;
height: 100%;
float: left;
}
#logo {
height: 100%;
top: 0;
left: 0;
width: 50%;
}
.header_title {
width: 60%;
float: left;
}
#titles {
position: absolute;
top: 20px;
font-family: "Times New Roman", Times, serif, Georgia;
font-size: 97%;
color: #B8B8B8;
}
ul {
list-style-type: none;
}
li {
display: inline-block;
}
a {
text-decoration: none;
color: inherit;
padding: 21px 10px;
}
li ul li {
padding: 21px 10px;
}
li a:hover {
background-color: #666699;
}
ul li ul {
display: none;
}
ul li:hover ul {
display: block;
position: absolute;
width: 100%;
top: 40px;
left: 0;
white-space: nowrap;
}
* {
border: 0;
margin: 0;
padding: 0;
}
.content {
height: 800px;
margin: auto;
background-color: #C0C0C0;
}
.footer {
margin: auto;
background-color: #000000;
}
<div class="header">
<div class="header_logo">
<img id="logo" src="civic-logo.jpg">
</div>
<div class="header_title">
<div id="titles">
<ul>
<li>PRODUCTS
<ul>
<li>CEMENT</li>
<li>STEEL</li>
<li>BRICKS</li>
<li>SAND</li>
</ul>
</li>
<li>CONTACT US </li>
</ul>
</div>
</div>
</div>
<div class="content">
</div>
<div class="footer">
</div>

formatted 3 columns adding up to 100%. But the last column is pushed down

As stated from the title, this is my html code.
<body>
<div id="wrapper">
<div id="nav">
<a href="#"><img class="logo" src="../media/images/Logo.png"
width="200px" height="200px" alt="Home" /></a>
<ul class="navUL">
<li>Home</li>
<li>Movies</li>
<li>Members</li>
<li>Management</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
<div id="mainPage"></div>
<div id="advertisement"></div>
</div>
</body>
My CSS is -
body, #wrapper
{
height:100%;
margin: 0;
padding: 0;
}
#wrapper
{
position: absolute;
width: 100%;
height: 100%;
display: block;
}
#nav
{
background-image: url(../media/images/NavBackground.png);
float: left;
width: 20%;
height: 100%;
}
#mainPage
{
background-image: url(../media/images/ContentBackground.png);
overflow: auto;
width: 64%;
height: 100%;
}
#advertisement
{
background-image: url(../media/images/ContentBackground.png);
float: right;
width: 16%;
height: 100%;
}
The last column, the advertisement is pushed to the bottom. The total adds up to 100% so I don't know what is wrong.
I want to post the picture but I cant because low rep. Im sorry for the lack of picture.
An item being pushed down is generally caused by floating elements. If you rearrange your HTML such that the advertisement is before your main page, it will fix your problem.
I have tested this with the following CSS:
body, #wrapper
{
height:100%;
margin: 0;
padding: 0;
}
#wrapper
{
position: absolute;
width: 100%;
height: 100%;
display: block;
}
#nav
{
background: red;
float: left;
width: 20%;
height: 100%;
}
#mainPage
{
background: yellow;
overflow: auto;
width: 64%;
height: 100%;
}
#advertisement
{
background: blue;
float: right;
width: 16%;
height: 100%;
}
And the following HTML:
<div id="nav">
<ul class="navUL">
<li>Home</li>
<li>Movies</li>
<li>Members</li>
<li>Management</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
<div id="advertisement">test</div>
<div id="mainPage">test</div>
</div>
See the following CSS
All divs inside wrapper have a left float and the total of the widths is 100%.
#wrapper {
position: absolute;
width: 100%;
height: 100%;
display: block;
}
#nav {
float: left;
width: 20%;
height: 100%;
}
#mainPage {
float: left;
width: 65%;
height: 100%;
}
#advertisement {
float: left;
width: 15%;
height: 100%;
}

Content not visible and div stretches

Here's my html. The problem I am having is that the 'box1' divs do not even display and the 'nav' bar extends itself. I have no idea why...
<div id="nav">
<ul>
<li><a class="selected" href="link1">Home</a></li>
<li>Services</li>
<li>About</li>
<li>Gallery</li>
<li>Contact</li>
</ul>
</div> <!--#nav-->
<div id="content">
<div class="wrapper">
<div class="box1">
TEXT
</div> <!--#box1-->
<div class="box1">
IMAGE
</div> <!--#box1-->
</div> <!--#wrapper-->
</div> <!--#content-->
And the CSS...
#nav {
background-color: #000;
}
#nav ul {
margin: 0 auto;
width: 80%;
}
#nav li {
display: inline;
}
#content {
margin: 0 auto;
width: 80%;
min-width: 720px;
}
.box1 {
width: 40%;
height: 100px;
float: left;
position: relative;
padding-left: 6.33%;
}
Suggestions?
.box1 {
width: 40%;
height: 100px;
position: relative;
padding-left: 6.33%;
border: 1px solid #000;
margin: 0 auto;
}
Preview >> http://jsfiddle.net/XJA4T/

Resources