I'm trying to design my nav (4 items in total) to be in circles each spaced about 20 px apart, located on the top right of my screen. I got everything to "work" design wise, however, now that every nav item appears how I want it (in its own a circle), when I go to have them all positioned on the upper right the first 3 nav items have disappeared and only the 4th nav item is visible. Please help!
HTML:
<div id="nav">
<ul>
<li> The Story </li>
<li> Design </li>
<li> Specs </li>
<li> Gallery </li>
</ul>
</div>
CSS:
.navbutton {
list-style-type: none;
text-transform: uppercase;
text-decoration: none;
display: block;
width: 100px;
height: 100px;
border-radius: 50px;
font-size: 14px;
color: #ffffff;
line-height: 108px;
text-align: center;
background: #4FA5B1;
position: absolute;
top: 50px;
right: 100px;}
ul {
width: 50x;
padding: 0;
margin: 0;
overflow: auto;
list-style-type: none;
}
li {
width: 20%;
margin: 15%;
}
What about this:
#nav{
position: absolute;
top: 50px;
right: 100px;
}
.navbutton {
list-style-type: none;
text-transform: uppercase;
text-decoration: none;
display: block;
width: 100px;
height: 100px;
border-radius: 50px;
font-size: 14px;
color: #ffffff;
line-height: 108px;
text-align: center;
background: #4FA5B1;
}
ul {
width: 100%;
padding: 0;
margin: 0;
overflow: auto;
list-style-type: none;
}
li {
width: 120px;
float: left;
}
<div id="nav">
<ul>
<li> The Story </li>
<li> Design </li>
<li> Specs </li>
<li> Gallery </li>
</ul>
</div>
Try:
#nav{
position: absolute;
top: 50px;
right: 100px;
}
.navbutton {
list-style-type: none;
text-transform: uppercase;
text-decoration: none;
display: block;
width: 100px;
height: 100px;
border-radius: 50px;
font-size: 14px;
color: #ffffff;
line-height: 108px;
text-align: center;
background: #4FA5B1;
}
ul {
width: 50x;
padding: 0;
margin: 0;
overflow: auto;
list-style-type: none;
}
li {
width: 20%;
margin: 15%;
}
It's because your navbutton elements have position: absolute so they overlap each other, i.e. only the last one is visible.
Try this snippet:
.navbutton {
list-style-type: none;
text-transform: uppercase;
text-decoration: none;
display: inline-block;
width: 100px;
height: 100px;
border-radius: 50px;
font-size: 14px;
color: #ffffff;
line-height: 108px;
text-align: center;
background: #4FA5B1;
position: relative; /* ADDED */
}
ul {
width: 50x;
padding: 0;
margin: 0;
overflow: auto;
list-style-type: none;
}
li {
width: 20%;
margin: 20px;
}
<div id="nav">
<ul>
<li> The Story </li>
<li> Design </li>
<li> Specs </li>
<li> Gallery </li>
</ul>
</div>
If you want the navigation to be in the top right corner of the page use this CSS:
#nav {
position: absolute;
top: 0;
right: 0;
}
#nav li {
display: inline-block;
}
.navbutton {
list-style-type: none;
text-transform: uppercase;
text-decoration: none;
display: inline-block;
width: 100px;
height: 100px;
border-radius: 50px;
font-size: 14px;
color: #ffffff;
line-height: 108px;
text-align: center;
background: #4FA5B1;
position: relative; /* ADDED */
}
ul {
width: 50x;
padding: 0;
margin: 0;
overflow: auto;
list-style-type: none;
}
li {
width: 100px;
margin: 20px;
}
#nav{
position:absolute;
top: 50px;
right: 100px;
}
.navbutton {
list-style-type: none;
text-transform: uppercase;
text-decoration: none;
display: inline-block;
width: 100px;
height: 100px;
border-radius: 50px;
font-size: 14px;
color: #ffffff;
line-height: 108px;
text-align: center;
background: #4FA5B1;
}
ul {
padding: 0;
margin: 0;
overflow: auto;
list-style-type: none;
}
li {
margin: 20px;
float:left;
}
Related
The navbar I created overlaps when I switch my site to a mobile view.
I tried making it fit-content, but it still overlaps. The part that overlaps is the listed items
#navBar {
overflow: hidden;
text-align: center;
border-top: double black 2px;
}
#navBar ul {
padding: 0;
list-style: none;
width: fit-content;
}
#navBar li {
display: inline;
padding-top: 23px;
position: relative;
}
#navBar a {
font-size: 20px;
padding-right: 20px;
text-decoration: none;
text-align: center;
border: 4px solid lime;
padding-bottom: 10px;
padding-top: 20px;
padding-left: 10px;
font-family: American Typewriter, serif;
color: #262626;
text-transform: uppercase;
border-radius: 0px 0px 25px 25px;
}
#navBar a:hover {
color: lime;
}
#navBar a::before {
content: '';
display: block;
height: 5px;
width: 100%;
background-color: lime;
position: absolute;
top: 0;
width: 0%;
transition: all ease-in-out 250ms;
}
#navBar::hover::before {
width: 100%;
}
<nav id="navBar">
<div class="bar">
<ul>
<li>Tab1</li>
<li>Tab2 </li>
<li> Tab3</li>
</ul>
</div>
</nav>
I expect the navbar items to be side by side but the actual result in them overlapping.
You can use inline-flex for that
change
#navBar ul {
padding: 0;
margin: 0; /* reset margin */
list-style: none;
width: fit-content;
}
#navBar li {
display: inline-flex; /* change to inline-flex and remove the padding */
position: relative;
}
#navBar {
overflow: hidden;
text-align: center;
border-top: double black 2px;
}
#navBar ul {
padding: 0;
margin: 0;
list-style: none;
width: fit-content;
}
#navBar li {
display: inline-flex;
position: relative;
}
#navBar a {
font-size: 20px;
padding-right: 20px;
text-decoration: none;
text-align: center;
border: 4px solid lime;
padding-bottom: 10px;
padding-top: 20px;
padding-left: 10px;
font-family: American Typewriter, serif;
color: #262626;
text-transform: uppercase;
border-radius: 0px 0px 25px 25px;
}
#navBar a:hover {
color: lime;
}
#navBar a::before {
content: '';
display: block;
height: 5px;
width: 100%;
background-color: lime;
position: absolute;
top: 0;
width: 0%;
transition: all ease-in-out 250ms;
}
#navBar::hover::before {
width: 100%;
}
<nav id="navBar">
<div class="bar">
<ul>
<li>Tab1</li>
<li>Tab2 </li>
<li> Tab3</li>
</ul>
</div>
</nav>
So I try to change li's vertical position but when I do the nav bar height is affected as well. What is the way to actually do that without affecting nav bar's height?
Here's the code:
body {
margin: 0px;
}
ul {
margin: 0px;
padding: 0px;
list-style: none;
padding-left: 5px;
padding-top: 10px;
background-color: #333;
overflow: hidden;
}
li {
float: left;
height: 30px;
width: 100px;
background-color: grey;
color: white;
margin-right: 4px;
text-align: center;
line-height: 30px;
font-weight: bold;
font-size: 15px;
}
li a {
text-decoration: none;
color: white;
display: block;
}
ul li:hover {
opacity: 0.8;
}
<ul>
<li>Home</li>
<li>My Profile</li>
<li>Settings</li>
</ul>
What is your goal here? To have the content centered or...?
It may be better to use flexbox here rather than set the padding-left: 850px; on your ul (also on your ul you could've used display: block; margin: 0 auto; to center it.) If you'd like, you can give your ul a defined height and use align-items to specify how it should be aligned vertically.
body {
margin: 0;
}
nav {
background-color: #333;
display: flex;
justify-content: center;
}
nav ul {
display: flex;
justify-content: center;
list-style: none;
margin: 0;
padding: 0;
height: 50px;
align-items: center;
}
li {
height: 30px;
width: 100px;
background-color: grey;
color: white;
margin-right: 4px;
text-align: center;
line-height: 30px;
font-weight: bold;
font-size: 15px;
}
li a {
text-decoration: none;
color: white;
display: block;
}
ul li:hover {
opacity: 0.8;
}
<body>
<nav>
<ul>
<li>Home</li>
<li>My Profile</li>
<li>Settings</li>
</ul>
</nav>
</body>
You can add position: relative; and a value for bottom or top- in my snippet bottom: 4px;:
This reserves the space originally taken by the element (without position: relative;), but moves the element according to the top/bottom/left/right settings, without affecting other elements.
body {
margin: 0px;
}
ul {
margin: 0px;
padding: 0px;
list-style: none;
padding-left: 5px;
padding-top: 10px;
background-color: #333;
overflow: hidden;
}
li {
float: left;
height: 30px;
width: 100px;
background-color: grey;
color: white;
margin-right: 4px;
text-align: center;
line-height: 30px;
font-weight: bold;
font-size: 15px;
position: relative;
bottom: 4px;
}
li a {
text-decoration: none;
color: white;
display: block;
}
ul li:hover {
opacity: 0.8;
}
<ul>
<li>Home</li>
<li>My Profile</li>
<li>Settings</li>
</ul>
I am trying to set up the footer, but I'm unable to remove the lines under the text. I also would like to change the color of the text. I tried using text decoration:none under .footer ul, but that was unsuccessful.
h2 {
text-align: center;
font-family: "Courier New";
color: beige;
font-size: 50px;
font-weight: 200;
text-shadow: -2px -2px black;
margin-bottom: -50px;
position: relative;
}
.head-link {
text-decoration: none;
color: aliceblue;
}
.head-link:hover {
margin: 20px auto 20px;
position: relative;
color: darkgoldenrod;
}
header {
background-image: url(https://i.imgur.com/xD3POCF.jpg);
position: absolute;
background-position: center;
max-width: 2000px;
width: 100%;
height: 100%;
top: 0;
background-repeat: no-repeat;
background-size: cover;
display: inline-block;
bottom: 40px;
}
.header-image {
background-size: cover;
}
.dropbtn {
background-color: transparent;
color: darkblue;
padding: 10px;
cursor: pointer;
font-family: monospace;
top: 0;
font-size: 15px;
width: 120px;
height: 50px;
border-color: black;
border-style: double;
align-content: center;
text-align: center;
margin-top: -10px;
}
.dropdown {
display: inline-block;
position: relative;
margin-left: 15px;
}
.dropdown-content {
padding: 12px;
position: absolute;
font-family: monospace;
background-color: transparent;
z-index: 1;
display: none;
min-width: 10px;
text-align: left;
left: 0;
}
.dropbtn:hover {
color: white;
}
.dropdown-content a {
color: #04116f;
padding: 12px 16px;
text-decoration: none;
display: block;
font-size: 13px;
}
.dropdown-content a:hover {
color: white;
}
.dropdown:hover .dropdown-content {
display: block;
text-decoration: underline;
}
.sidebar {
display: block;
position: relative;
top: -650px;
bottom: 0px;
left: -30px;
width: 120px;
padding: 10px;
background: transparent;
z-index: 0;
}
.sidebar ul {
cursor: pointer;
list-style: none;
color: white;
line-height: 2;
}
body {
margin: 0px;
top: 0;
width: 100%;
max-height: 10%;
background-image: url(http://i.imgur.com/yiMoYpV.jpg);
background-size: cover;
background-repeat: no-repeat;
background-position: 20px 50px center;
background-attachment: fixed;
}
.content {
display: block;
margin-right: 0px;
padding: 0px;
margin-bottom: 700px;
position: relative;
max-width: 1500px;
max-height: 500px;
}
p {
display: block;
padding: 40px;
position: relative;
max-width: 500px;
max-height: 500px;
width: 100%;
left: 50%;
height: 200px;
top: 120px;
font-family: monospace;
font-size: 15px;
line-height: 2;
margin-bottom: -70px;
color: goldenrod;
text-align: left;
}
.footer {
margin: 100px 0 0 0;
display: flex;
flex-flow: row;
justify-content: center;
padding-bottom: 2px;
align-content: space-between;
background: transparent;
overflow: hidden;
}
.footer ul {
text-align: center;
list-style: none;
display: inline-flex;
color: white;
text-decoration: none;
}
<!DOCTYPE html>
<html>
<header>
<h2 style="bottom: -130px">
<a href="#" class=h ead-link> A B E L</a>
</h2>
<div class="dropdown" style="float;right">
<button class="dropbtn">Menu</button>
<div class="dropdown-content" style="right;0">
About
Portfolio
Contact
</div>
</div>
<div class="title"></div>
<title>A B E L </title>
</header>
<body>
<div id="hl-content" class="content"></div>
<p>
<span style="color:navajowhite">
<b>Hello, Welcome to my website.</b>
</span>
<BR></BR>
My name is Abel, a senior college student currently residing in the Bay Area. This portfolio will give you a good background about me including my specialties, expertise and even hobbies. As you can probably tell from the background pictures, I like traveling
and taking photos!
</p>
<p>This is my first ever website that I created using HTML and CSS, and it's a pleasure to finally be able to share it with you. I am happy to receive any feedback, recommendations or opportunities from you, so don't hesitate to contact me.</p>
<div class="footer">
<ul>
<li> About</li>
<li>Portfolio</li>
<li> Contact </li>
</ul>
</div>
</body>
</html>
As you can see text decoration and color doesn't work.
How can I fix this?
.footer > ul > li > a {
color: white;
text-decoration: none;
}
Try this.
You need to style the links in your footer explicitly.
.footer ul a {
text-decoration:none;
}
You need to add this css :
.footer ul li a {
text-decoration:none;
}
I've tried my best, this might help as per your requirement(underline and color):
add this in your code,
.footer ul li a {
text-decoration: none;
color: tan;
padding: 5px;
}
.footer ul li a:hover {
text-decoration: underline;
}
appreciate if it is useful enough.
I have a problem with putting an img for hover background.
It should look like this : Navigation
These 2 lines, represent the hover transparent image, and the text "home" should be in center of that img.. I have no idea how to do that... Anyone ?
Sorry if my english is bad
.page-container {
width: 980px;
margin: 0 auto;
text-align: center;
}
header {
margin: 0;
padding: 0;
width: 100%;
height: 220px;
background-color: #EAEAEA;
}
.logo {
text-align: center;
}
.logo img {
margin: 30px 0 0 0;
}
nav {
height: 136px;
}
ul {
list-style-type: none;
display: inline-block;
margin: 70px 0 0 0;
padding: 0;
}
nav li {
float: left;
text-align: center;
}
nav li a {
margin-right: 165px;
text-decoration: none;
float:left;
font-size: 22px;
letter-spacing: 3px;
text-transform: uppercase;
font-family: font91477;
color: #9E9E9E;
background-size: 75px;
}
a:focus {
text-decoration: none;
color: #9E9E9E;
}
a:hover {
height: 75px;
text-decoration: none;
color: #9E9E9E;
background: url(http://i.imgur.com/P5tF09r.png) no-repeat center;
}
<header>
<div class="logo">
<img src="img/logo.png"/>
</div>
<nav>
<div class="page-container">
<ul>
<li>Home</li>
<li>O Podjetju</li>
<li>Produkti</li>
<li><a class="last-child" href="#">Kontakti</a></li>
</ul>
</div>
</nav>
</header>
just add the following css styles
a:hover {
height: 75px;
text-decoration: none;
color: #9E9E9E;
background: url(http://i.imgur.com/P5tF09r.png) no-repeat center;
/*****************here they are ************/
display:flex;
align-items: center;
}
Why you don't make it in css ? Something like this
.menu{
list-style: none;
background-color: #EAEAEA;
margin: 0;
padding: 20px 0;
overflow: hidden;
}
.menu__item{
float: left;
margin: 0 20px;
position: relative;
}
.menu__item a{
background-color: #EAEAEA;
text-transform: uppercase;
position: relative;
z-index: 1;
}
.menu__item::after{
content:'';
width: 1px;
height: 1px;
background-color: #000;
position: absolute;
top: 50%;
left: 50%;
margin: 0;
transform: rotate(-45deg);
z-index: 0;
transition: all .25s ease;
}
.menu__item:hover::after{
width: 50px;
margin: -1px 0 0 -25px;
}
<ul class="menu">
<li class="menu__item"><a>Home</a></li>
<li class="menu__item"><a>test</a></li>
<li class="menu__item"><a>very long title for test</a></li>
<li class="menu__item"><a>test</a></li>
</ul>
I have OCD and the following needs to be fixed (the spacing of word's in my navigation bar).
body {
width: 100%;
background-color: #e6e6e6;
font-family: Miramonte;
margin: auto;
}
.navContainer {
height: 30px;
width: 100%;
margin: auto;
padding-top: 30px;
}
nav {
width: 100%;
max-width: 400px;
background-color: #333;
padding: 0;
margin: 1em auto;
overflow: visible;
height: 30px;
}
nav ul {
overflow: visible;
height: 30px;
margin: 0;
padding: 0;
}
nav ul li {
text-align: center;
overflow: visible;
height: 30px;
margin: 0;
padding: 0;
list-style-type: none;
float: left;
width: 20%;
max-width: 80px;
display: block;
}
a {
text-decoration: none;
margin: 0;
padding: 0;
color: #d9d9d9;
overflow: visible;
line-height: 30px;
display: block;
position: relative;
}
a:hover {
color: #e6e6e6;
}
a img {
width: 90%;
margin: 0;
padding: 0;
vertical-align: baseline;
position: absolute;
bottom: -30px;
right: 5%;
left: 5%;
}
<div class="navContainer">
<nav>
<ul>
<li> art
</li>
<li> download
</li>
<li>
<a href="home.html">
<img src="image/symbol.png">
</a>
</li>
<li> portfolio
</li>
<li> product
</li>
</ul>
</nav>
</div>
All I need is the words to be evenly spread out with the image still intact in the middle like the picture dictates.
Notice how the word art is unevenly spread compared to the right side?
I am the first one to say that I am building my own website and I am new to CSS/HTML scripting.
Appreciate the help,
Thanks.
Use display: table / table-cell for the list / list items.
body {
width: 100%;
background-color: #e6e6e6;
font-family: Miramonte;
margin: auto;
}
.navContainer {
height: 30px;
width: 100%;
margin: auto;
padding-top: 30px;
}
nav {
width: 100%;
list-style: none;
max-width: 400px;
background-color: #333;
padding: 0;
margin: 1em auto;
overflow: visible;
height: 30px;
}
nav ul:before {
display: table;
content: " ";
}
nav ul {
overflow: visible;
height: 30px;
margin: 0;
padding: 0;
}
nav ul li {
text-align: center;
overflow: visible;
height: 30px;
margin: 0;
padding: 0;
list-style-type: none;
float: none;
width: 1%;
max-width: 80px;
display: table-cell;
position: relative;
}
a {
text-decoration: none;
margin: 0;
padding: 0;
color: #d9d9d9;
overflow: visible;
line-height: 30px;
display: block;
position: relative;
}
a:hover {
color: #e6e6e6;
}
a img {
width: 90%;
margin: 0;
padding: 0;
vertical-align: baseline;
position: absolute;
bottom: -30px;
right: 5%;
left: 5%;
}
Removing the float: left and the display: block from the nav ul li CSS selector and then adding
display: flex;
flex-flow: row wrap;
justify-content: space-between;
to the nav ul CSS selector will change the display from block to flexible boxes, allowing for the text to be more evenly spread out throughout the entire element
body {
width: 100%;
background-color: #e6e6e6;
font-family: Miramonte;
margin: auto;
}
.navContainer {
height: 30px;
width: 100%;
margin: auto;
padding-top: 30px;
}
nav {
width: 100%;
max-width: 400px;
background-color: #333;
padding: 0;
margin: 1em auto;
overflow: visible;
height: 30px;
}
nav ul {
overflow: visible;
height: 30px;
margin: 0;
padding: 0;
display: flex;
flex-flow: row wrap;
justify-content: space-around;
}
nav ul li {
text-align: center;
overflow: visible;
height: 30px;
margin: 0;
padding: 0;
list-style-type: none;
// float: left;
width: 20%;
max-width: 80px;
// display: block;
flex: 1;
}
a {
text-decoration: none;
margin: 0;
padding: 0;
color: #d9d9d9;
overflow: visible;
line-height: 30px;
display: block;
position: relative;
}
a:hover {
color: #e6e6e6;
}
a img {
width: 90%;
margin: 0;
padding: 0;
vertical-align: baseline;
position: absolute;
bottom: -30px;
right: 5%;
left: 5%;
}
<body>
<div class="navContainer">
<nav>
<ul>
<li> art
</li>
<li> download
</li>
<li>
<a href="home.html">
<img src="image/symbol.png">
</a>
</li>
<li> portfolio
</li>
<li> product
</li>
</ul>
</nav>
</div>
</body>
EDIT:
I added a few characters around the word art in the link to give it some spacing to resemble the other links.
is how you create whitespace in HTML
Something like this (with slightly changed markup)?
body {
width: 100%;
background-color: #e6e6e6;
font-family: Miramonte;
margin: auto;
}
.navContainer {
height: 30px;
width: 100%;
margin: auto;
padding-top: 30px;
}
nav {
width: 100%;
max-width: 400px;
background-color: #333;
padding: 0;
margin: 1em auto;
display: flex;
height: 30px;
}
nav ul {
display: flex;
height: 30px;
margin: 0;
padding: 0;
}
nav ul:nth-child(1), nav ul:nth-child(3) {
flex: 1;
justify-content: space-between;
}
nav ul:nth-child(1)::before, nav ul:nth-child(3)::before,
nav ul:nth-child(1)::after, nav ul:nth-child(3)::after{
content: '';
}
nav ul:nth-child(2) {
width: 18%;
}
nav ul li {
text-align: center;
overflow: visible;
height: 30px;
margin: 0;
padding: 0;
list-style-type: none;
max-width: 80px;
display: block;
}
nav ul:nth-child(2) li {
width: 100%;
}
a {
text-decoration: none;
margin: 0;
padding: 0;
color: #d9d9d9;
overflow: visible;
line-height: 30px;
display: block;
position: relative;
}
a:hover {
color: #e6e6e6;
}
a img {
width: 100%;
margin: 0;
padding: 0;
vertical-align: baseline;
position: absolute;
bottom: -30px;
left: 0%;
}
<div class="navContainer">
<nav>
<ul>
<li> art </li>
<li> download </li>
</ul>
<ul>
<li><img src="http://www.pd4pic.com/images/eye-black-fan-symbol-design-sun-flower-circle.png"></li>
</ul>
<ul>
<li> portfolio </li>
<li> product </li>
</ul>
</nav>
</div>
Try this, just change the nav percentage as per your requirement. Also for more accurate results you can add media query.
body {
width: 100%;
background-color: #e6e6e6;
font-family: Miramonte;
margin: auto;
}
.navContainer {
height: 30px;
width: 100%;
margin: auto;
padding-top: 30px;
}
nav {
width: 100%;
list-style: none;
max-width: 75%;
background-color: #333;
padding: 0;
margin: 1em auto;
overflow: visible;
height: 30px;
}
nav ul:before {
display: table;
content: " ";
}
nav ul {
overflow: visible;
height: 30px;
margin: 0;
padding: 0;
}
nav ul li {
text-align: center;
overflow: visible;
height: 30px;
margin: 0;
padding: 0;
list-style-type: none;
float: none;
width: 1%;
max-width: 80px;
display: table-cell;
position: relative;
}
a {
text-decoration: none;
margin: 0;
padding: 0;
color: #d9d9d9;
overflow: visible;
line-height: 30px;
display: block;
position: relative;
}
a:hover {
color: #e6e6e6;
}
a img {
width: 100%;
margin: 0;
padding: 0;
vertical-align: baseline;
position: absolute;
bottom: -30px;
right: 0;
left: 0;
}
<body>
<div class="navContainer">
<nav>
<ul>
<li> art
</li>
<li> download
</li>
<li>
<a href="home.html">
<img src="image/symbol.png">
</a>
</li>
<li> portfolio
</li>
<li> product
</li>
</ul>
</nav>
</div>
</body>