I have a vertical NavBar which is in a wrapper. It works fine but the rest of my content follows below it. I'd like to have the Vert Narbar on the Left maybe 20% width, and the content on the Right. I'll need to use a Clear for my footer.
The Navbar CSS [omitting some unecessary lines] is:
div.wrapper {
margin: 60px auto auto 8px;
width: 220px;
}
p {
/*4spaces*/
font-family: georgia;
font-size: 1rem;
line-height: 25px;
margin: 24px 0;
text-align: center;
}
nav.vertical {
border-radius: 14px;
box-shadow: 0 0 10px rgba(0, 0, 0, .15);
overflow: hidden;
text-align: center;
}
nav.vertical>ul {
list-style-type: none;
}
nav.vertical>ul>li {
display: block;
}
nav.vertical>ul>li>a {
background-color: rgb(157, 34, 60);
text-shadow: 0 1px 1px rgba(0, 0, 0, .1);
text-transform: uppercase;
transition: all .35s ease;
/*4spaces */
}
nav.vertical>ul>li>a:hover {
background-color: rgb(114, 51, 98);
cursor: pointer;
}
nav.vertical>ul>li>div {
background-color: rgb(255, 255, 255);
}
nav.vertical>ul>li>div>ul {
list-style-type: none;
}
nav.vertical>ul>li>div>ul>li>a {
background-color: rgb(255, 255, 255);
border-bottom: 1px solid rgba(0, 0, 0, .05);
color: #333331;
display: block;
font-size: 1.1rem;
padding: 10px 0;
text-decoration: none;
transition: all 0.35s linear;
}
nav.vertical>ul>li>div>ul>li:hover>a {
background-color: lightBlue;
color: rgb(255, 255, 255);
padding: 10px 0 10px 50px;
}
<!-- 4 spaces -->
<div class="wrapper">
<nav class="vertical">
<ul>
<li>
Category 1
<div>
<ul>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
</div>
<!-- 4 spaces -->
</li>
<li>
Category 2
<div>
<ul>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
</div>
</li>
</ul>
</nav>
<!-- 4 spaces -->
</div>
<div style="padding-left:20px">
<h1>Website Content Stuff</h1>
</div>
<!-- main content -->
<p>Ipsorum pro loekum text that we all hate</p>
I should mention that I got the Navbar code online from Adam-Bray
You have to add a float on your .wrapper div, because it's a block element so it takes the full width and moves the content below it
Related
I have 1 row of 3 divs. The rows on the edges (1,3) are arrow indicators. Edge/Column 1 has an arrow indicating left; edge/column3 has an arrow indicating right. The middle column (2) is scrollable. I want for when the middle column, the edges remain intact.
In the code example. The first column remains while the middle column scroll but the third column (right arrow) disappears.
Please and thank you in advanced.
body {
font-family: sans-serif;
color: #3d85c6;
}
.letter-changer {
animation: example 5s linear 2s infinite alternate;
}
ul.mp-0,
.mp-0 {
margin: 0;
padding: 0;
}
div.lk-shadow{
-webkit-box-shadow: 5px 7px 9px 0px rgba(0, 0, 0, 0.6);
box-shadow: 5px 7px 9px 0px rgba(0, 0, 0, 0.6);
}
div.lk-verb-box {
position: relative;
overflow: hidden;
vertical-align: middle;
width: 300;
min-width: 150px;
white-space: nowrap;
overflow-x: auto;
}
div.lk-verb-border {
margin: 5px;
}
.lk-scroll-arrow {
height: 10px;
width: 10px;
text-align: center;
line-height: 40px;
vertical-align: middle;
}
ul.lk-verb {
list-style: none;
padding: 0%;
word-spacing: 0%;
white-space: nowrap;
overflow-y: hidden;
overflow-x: auto;
display: block;
padding: 5px;
}
li.lk-verb {
display: inline-block;
background-color: white;
color: #3d85c6;
border: solid 1px #3d85c6;
height: 20px;
padding: 5px;
padding-left: 7px;
padding-right: 7px;
border-radius: 5px;
}
li.lk-verb:hover {
background-color: #3d85c6;
color: white;
cursor: pointer;
}
.lk-fl {
float: left;
}
.lk-ele-box {
overflow-x: auto;
}
#keyframes example {
from {
transform: translateX(0);
}
to {
transform: translateX(140px);
}
}
</style>
<script type="text/javascript">
document.addEventListener("keypress", function (e) {
var el = document.getElementById("vbr10");
el.scrollIntoView(true);
});
<div class="lk-shadow" style="padding-right: 5px;">
<div class="lk-scroll-arrow lk-fl" style="display: table-cell;">🢔</div>
<div class="lk-verb-box" >
<ul class="lk-verb mp-0 lk-fl">
<li id="vrb1" class="lk-verb">Element 1</li>
<li id="vrb2" class="lk-verb">Element 1</li>
<li id="vrb3" class="lk-verb">Element 2</li>
<li id="vrb4" class="lk-verb">Element 0</li>
<li id="vrb5" class="lk-verb">Element 3</li>
<li id="vrb6" class="lk-verb">Element 4</li>
<li id="vrb7" class="lk-verb">Element 5</li>
<li id="vrb8" class="lk-verb">Element 6</li>
<li id="vrb9" class="lk-verb">Element 7</li>
<li id="vrb10" class="lk-verb">Element 8</li>
<li id="vrb11" class="lk-verb">Element 9</li>
</ul>
<div class="lk-scroll-arrow lk-fl" style="display: table-cell;">🢖</div>
</div>
</div>
I am new to css
I am trying to develop a navigation bar for website it works fine when it is in full screen, but when i decrease the size of window few elements came down but the background colour remain intact to first row only.
Here's the code
.navbar {
background-color: rgb(11, 29, 66);
height: 60px;
border-radius: 0px;
}
.navbar ul {
margin: 0px;
padding: 0px;
overflow: auto;
}
.navbar li {
float: left;
list-style: none;
margin: 10px 10px;
border-right: 2px solid gold;
}
.navbar li a {
text-decoration: none;
color: khaki;
padding-right: 0.5cm;
font-family: 'Big Shoulders Stencil Display', cursive;
font-size: 28px;
}
<nav class="navbar">
<ul>
<li>
<img src="favicon-32x32.png" alt="Home">
</li>
<li>Element 1</li>
<li>Element 2</li>
<li>Element 3</li>
<li>Element 4</li>
<li>Element 5</li>
</ul>
</nav>
It's your height property on the navbar. I removed it, run the snippet below:
.navbar {
background-color: rgb(11, 29, 66);
border-radius: 0px;
}
.navbar ul {
margin: 0px;
padding: 0px;
overflow: auto;
}
.navbar li {
float: left;
list-style: none;
margin: 10px 10px;
border-right: 2px solid gold;
}
.navbar li a {
text-decoration: none;
color: khaki;
padding-right: 0.5cm;
font-family: 'Big Shoulders Stencil Display', cursive;
font-size: 28px;
}
<nav class="navbar">
<ul>
<li>
<img src="favicon-32x32.png" alt="Home">
</li>
<li>Element 1</li>
<li>Element 2</li>
<li>Element 3</li>
<li>Element 4</li>
<li>Element 5</li>
</ul>
</nav>
You can add the background color to your .navbar ul
like this :
.navbar ul {
margin: 0px;
padding: 0px;
overflow: auto;
background-color: blue;
}
I want the first row of my container (the one with logo and button) to be 100% gray, as it is.
However, I'm having trouble with the second row. I want the second row to be yellow. But I can't seem to make it happen.
The color of the container keeps invading the second row. How do I make the second row to be 100% wide and yellow? I've tried width: 100%, but it didn't solve the problem.
body {
background-color: rgb(210, 210, 210);
margin: 0px;
padding: 0px;
}
#container {
padding-top: 10px;
padding-bottom: 10px;
padding-left: 10px;
padding-right: 10px;
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: baseline;
background-color: rgb(97, 97, 97);
}
#Hyperlinks {
text-align: right;
background-color: darkgoldenrod;
}
#Logo {
width: 20%;
}
#Button {
width: 80%;
text-align: right;
}
#Button button {
margin-right: 40px;
background-color: rgba(27, 129, 107, 0.5);
border: none;
color: white;
padding: 10px 15px;
text-align: center;
text-decoration: none;
font-size: 16px;
}
#Logo p {
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande';
font-size: 1.2rem;
color: white;
padding-left: 40px;
}
#Hyperlinks a {
font-size: 1.2rem;
text-align: center;
text-decoration: none;
color: white;
padding-right: 5px;
}
#Hyperlinks ul {
text-align: left;
padding-inline-start: 0;
margin-block-start: 0;
margin-block-end: 0;
margin-left: 40px;
}
#Hyperlinks>ul>li {
display: block;
padding: 10px 50px 10px 2px;
margin-right: 10px;
}
#Hyperlinks ul ul {
display: none;
}
<nav>
<div id="container">
<div id="Logo">
<p>MySitee.com</p>
</div>
<div id="Button">
<button type="button">Click me</button>
</div>
<div id="Hyperlinks">
<ul>
<li>Home</li>
<li>Tutorial
<ul>
<li>Tutorial 1</li>
<li>Tutorial 2</li>
<li>Tutorial 3</li>
</ul>
<!-- repare onde o li é quebrado... esse ul fica dentro dele, filho msm -->
</li>
<li>About</li>
<li>Newsletter
<ul>
<li>News 1</li>
<li>News 2</li>
<li>News 3</li>
</ul>
</li>
<li>Contact</li>
</ul>
</div>
</div>
</nav>
To remove the gray color which is invaded by #container, it is needed to fill the empty space with the #hyperlink and this can be done using flex-grow: 1.
And still, you can see the gray borders. This was made by the padding option of #container class. And to remove it on child #hyperlink class, it is needed to set the margin css attribute with the reverse value of parent padding css. So for example, if #container contains padding-left: 10px;, to remove it, it is needed to set margin-left: -10px css on #hyperlink.
body{
background-color: rgb(210,210,210);
margin:0px;
padding: 0px;
}
#container{
padding-top: 10px;
padding-bottom: 10px;
padding-left: 10px;
padding-right:10px;
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: baseline;
background-color: rgb(97, 97, 97);
}
#Hyperlinks{
text-align: right;
background-color: darkgoldenrod;
flex-grow: 1;
margin-left: -10px;
margin-right: -10px;
margin-bottom: -10px;
}
#Logo{
width: 20%;
}
#Button{
width: 80%;
text-align: right;
}
#Button button{
margin-right: 40px;
background-color: rgba(27, 129, 107,0.5);
border: none;
color: white;
padding: 10px 15px;
text-align: center;
text-decoration: none;
font-size: 16px;
}
#Logo p{
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande';
font-size: 1.2rem;
color: white;
padding-left: 40px;
}
#Hyperlinks a{
font-size: 1.2rem;
text-align: center;
text-decoration: none;
color: white;
padding-right: 5px;
}
#Hyperlinks ul{
text-align: left;
padding-inline-start: 0;
margin-block-start: 0;
margin-block-end: 0;
margin-left: 40px;
}
#Hyperlinks>ul>li{
display: block;
padding: 10px 50px 10px 2px;
margin-right: 10px;
}
#Hyperlinks ul ul{
display: none;
}
<header>
<nav>
<div id="container">
<div id="Logo">
<p>MySitee.com</p>
</div>
<div id="Button">
<button type= "button">Click me</button>
</div>
<div id="Hyperlinks">
<ul>
<li>Home</li>
<li>Tutorial
<ul>
<li>Tutorial 1</li>
<li>Tutorial 2</li>
<li>Tutorial 3</li>
</ul>
<!-- repare onde o li é quebrado... esse ul fica dentro dele, filho msm -->
</li>
<li>About</li>
<li>Newsletter
<ul>
<li>News 1</li>
<li>News 2</li>
<li>News 3</li>
</ul>
</li>
<li>Contact</li>
</ul>
</div>
</div>
</nav>
</header>
i am trying to make a mega menu with border to look good but the border is not 100% width of box here is my code :
.mega-menu {
display: block;
overflow: hidden;
position: absolute;
top: 90px;
max-width: 630px;
background: rgb(45, 98, 214);
z-index: 1;
padding: 10px;
}
.mega-menu a {
display: block;
color: white;
margin: 5px;
font-size: 15px;
border-bottom: 1px solid rgba(255, 255, 255, 0.45);
}
.row-reset {
margin-left: 0;
margin-right: 0;
}
<div class="mega-menu">
<div class="row row-reset">
<div class="col-xl-6">
<ul>
<li>test 1</li>
<li>test 2 </li>
<li>test 3</li>
</ul>
</div>
<div class="col-xl-6">
<ul>
<li>test 4</li>
<li>test 5 </li>
<li>test 6</li>
</ul>
</div>
</div>
</div>
here is what i mean i want the border to be from this :
From This to This
since you are using bootstrap you need to customize each element.
.mega-menu {
display: block;
overflow: hidden;
position: absolute;
top: 90px;
max-width: 630px;
background: rgb(45, 98, 214);
z-index: 1;
}
.mega-menu a {
display: block;
color: white;
margin: 5px;
font-size: 15px;
}
.row-reset {
margin-left: 0;
margin-right: 0;
}
.mega-menu > div > div {
padding: 0;
}
.mega-menu > div > div ul {
padding: 0;
margin-bottom: 0rem;
}
.mega-menu > div > div ul li {
list-style: none;
border: 1px solid #ffffff;
padding: 5px 25px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<div class="mega-menu">
<div class="row row-reset">
<div class="col-xl-6">
<ul>
<li>test 1</li>
<li>test 2 </li>
<li>test 3</li>
</ul>
</div>
<div class="col-xl-6">
<ul>
<li>test 4</li>
<li>test 5 </li>
<li>test 6</li>
</ul>
</div>
</div>
</div>
.mega-menu{
display: block;
overflow: hidden;
position: absolute;
top: 90px;
max-width: 630px;
background: rgb(45, 98, 214);
z-index: 1;
padding: 10px;
}
.mega-menu a{
display: block;
color: white;
margin: 5px;
font-size: 15px;
}
.row-reset{
margin-left: 0;
margin-right: 0;
}
.row-reset ul{
padding-left: 0;
}
.row-reset ul li{
border-bottom: 1px solid rgba(255, 255, 255, 0.45);
list-style: none;
}
.row-reset ul li:last-child {
border-bottom: 0px;
}
.row-reset .column ul{
border-right: 1px solid rgba(255, 255, 255, 0.45);
}
.row-reset .column:last-child ul{
border-right: 1px solid transparent !important;
}
<div class="mega-menu">
<div class="row row-reset">
<div class="col-xl-6 column px-0">
<ul>
<li>test 1</li>
<li>test 2 </li>
<li>test 3</li>
</ul>
</div>
<div class="col-xl-6 column px-0">
<ul>
<li>test 4</li>
<li>test 5 </li>
<li>test 6</li>
</ul>
</div>
</div>
</div>
You could do it as follows. It is mostly bootstrap which will be easy to code. I have used table in this case which would probably be a better choice in this case.
.mega-menu {
display: block;
overflow: hidden;
position: absolute;
top: 90px;
max-width: 630px;
background: rgb(45, 98, 214);
z-index: 1;
padding: 10px;
}
.mega-menu a {
display: block;
color: white;
margin: 5px;
font-size: 15px;
border-bottom: 1px solid rgba(255, 255, 255, 0.45);
}
.table,
td {
border: 1px solid white !important;
background-color: blue;
width: 260px !important;
font-weight: 730;
font-size: 22px;
}
td {
padding: 5px 20px !important;
}
* {
color: white !important;
}
.row-reset {
margin-left: 0;
margin-right: 0;
}
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
</head>
<div class='container'>
<table class="table table-hover table-bordered font-weight-bolder table-sm mt-5">
<tbody>
<tr>
<td>test 1</td>
<td>test 4 </td>
</tr>
<tr>
<td> test 2</td>
<td>test 5 </td>
</tr>
<tr>
<td> test 3</td>
<td>test 6 </td>
</tr>
</tbody>
</table>
<div>
</div>
Hope this helps !
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I'm working on navbar dropdown menu and him having some trouble trying to position the dropdown menu with a width 100% but when every I put width to 100% it expands to right but not the left side.
Here the link to a preview of my project working on. Hope someone by can help with the small quick problem having.
Preview Link --> https://brandonpowell.github.io/alegacyleftbehind/
This is what trying to accomplish
HTML
<nav class="navbar-default primary-nav navbar-fixed-top nav-down">
<div class="container-fluid">
<div class="row">
<div class="top-navbar">
<div class="media-icons">
<i class="fa fa-facebook-official" aria-hidden="true"></i>
<i class="fa fa-instagram" aria-hidden="true"></i>
<i class="fa fa-twitter-square" aria-hidden="true"></i>
</div>
</div>
<a href="#"><div class="donate-button">
<p>Donate</p>
</div></a>
<div class="bottom-navbar">
<div class="logo">Logo Here</div>
<div class="nav-menu"><img src="icons/menu.svg"></div>
<ul class="navbar">
<li>Home</li>
<li>Founder's Message</li>
<li>About Us
<ul class="nav-content">
<li>dropdown item 1</li>
<li>dropdown item 2</li>
<li>dropdown item 3</li>
<li>dropdown item 4</li>
<li>dropdown item 5</li>
<li>dropdown item 6</li>
</ul>
</li>
<li>Join Our Team</li>
<li>News & Events</li>
<li>Campus Clubs</li>
<li>Resources</li>
<li>Contact Us</li>
</ul>
</div>
</div>
</div>
</nav>
CSS
body, html {
margin: 0px;
padding: 0px;
box-sizing: border-box; }
nav .top-navbar {
background-color: #212121;
position: absolute;
height: 67px;
width: 100%; }
.donate-button {
position: relative;
float: right;
top: 0px;
z-index: 1; }
.donate-button p {
font-style: Montserrat, sans-serif;
background-color: #961de7;
letter-spacing: 1px;
padding: 21.4px 35px;
margin-bottom: 0px;
font-weight: bold;
text-transform: uppercase;
color: white; }
.bottom-navbar {
background-color: white;
width: 100%;
display: inline-block;
-webkit-box-shadow: 0px 10px 0px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0px 10px 0px rgba(0, 0, 0, 0.2);
box-shadow: 0px 10px 0px rgba(0, 0, 0, 0.2); }
.nav-menu {
display: none; }
.navbar {
display: table; }
.navbar a:hover {
color: pink; }
.navbar li {
display: table-cell;
list-style-type: none;
padding: 0;
margin: 0;
font-size: 14px;
letter-spacing: 0.5px;
font-weight: bold;
text-transform: uppercase; }
.navbar li a {
text-decoration: none;
color: #212121; }
.nav-content {
position: absolute;
top: 13.3em;
z-index: -1;
padding: 1.3em 0 !important;
overflow: hidden;
width: 100%;
background-color: #a656dc; }
.nav-content a {
color: white;
text-decoration: none; }
.logo {
background-color: #961de7;
color: white;
font-size: 16pt;
float: left;
padding: 39px 6%; }
you need to add a value for 'left' to the nav-content div like this:
.nav-content {
position: absolute;
top: 13.3em;
z-index: -1;
padding: 1.3em 0 !important;
overflow: hidden;
width: 100%;
background-color: #a656dc;
left: 0; /*add this*/
}
and to center the menu add margin:auto to the ul element like this:
.nav-content ul {
margin:auto;
}