CSS/HTML fixed nav bar overlapping content - html

I have made a nav bar that sticks to the top of the page, but it is sticking to some of the content and I have tried using margin-top: 100px; in the CSS file but that just moves the nav bar down 100px. Anyone have any ideas?
Link to js fiddle
CSS
.con {
overflow: hidden;
background: #159B00;
width: 1000px;
height: 376px;
border-radius: 10px;
border: 2px solid black;
box-shadow: 0 4px 8px black;
}
.nav {
padding-top: 0px;
background: #fff;
height: auto;
width: 100%;
z-index: 150;
top: o;
position: fixed;
box-shadow: 0 2px 3px rgba(0,0,0,.4);
}
HTML
<div class="nav">
<div id="nav_wraper">
<ul>
<li><a href="RUN ME.html">
</div>
</a></li>
</a>
</li><li>
Home
</li><li>
Designs▼
<ul>
</ul>
</li><li>
About▼
<ul>
</ul>
</li><li>
Contact▼
<ul>
</ul>
</li>
</ul>
</div>
</div>
<main>
<div id="iG" class="con" >
<img src="slider.png" alt="" />
<img src="step_1.png" alt="" />
<img src="step_2.png" alt="" />
<img src="step_3.png" alt="" />
<img src="slider.png" alt="" />
</div>
</main>
Thanks.

You can fix this by adding
body{
padding-top:100px;
}
and you have syntax error in
.nav{
top:o;
}
should be
.nav{
top:0;
}
updated fiddle

Related

I cannot align the footer to the right

I would like to know if someone could help me with a CSS topic.
I am creating a page model through CSS, but it turns out that there is a part that does not stay the same as the rest.
It appears as follows:
enter image description here
And it should look like this, like the footer in the following image.
Do you suggest any ideas? I leave here the code that I have used for CSS.
enter image description here
I attach the HTML and CSS code used.
I tried to move the height and width but can't find the solution.
<!--Inicio de pie de página-->
<div class="clearfix"></div>
<footer id="footer">
<div class="wrap">
<div id="menu_footer">
<h5>Menú</h5>
<ul>
<li>Inicio</li>
<li>Blog Personal</li>
<li>Currículum</li>
<li>Contacto</li>
</ul>
</div>
<div id="location">
<h5>¿Dónde estamos?</h5>
<iframe
src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3037.4968410733713!2d-3.690925684351!3d40.41999606336424!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0xd42289a4a865227%3A0x98278b3a144a86f1!2sPuerta%20de%20Alcal%C3%A1!5e0!3m2!1ses!2ses!4v1599489227264!5m2!1ses!2ses"
width="600" height="450" frameborder="0" style="border:0;" allowfullscreen="" aria-hidden="false"
tabindex="0">
</iframe>
<div id="info">
<h5> Desarrollado con</h5>
<p>
<img src="img/html5-badge-h-css3-graphics-multimedia-performance-semantics.png"
alt="Creado con HTML y CSS">
</p>
<h5>Optimizado para</h5>
<p id="browsers">
<a href="#">
<img src="img/firefox-icon.png" alt="Firefox" title="Firefox">
</a>
<a href="#">
<img src="img/chrome.png" alt="chrome" title="Chrome">
</a>
<a href="#">
<img src="img/Opera_256x256.png" alt="Opera" title="Opera">
</a>
<a href="#">
<img src="img/safari.png" alt="Safari" title="Safari">
</a>
<a href="#">
<img src="img/android.png" alt="Android" title="Android">
</a>
<a href="#">
<img src="img/ios.png" alt="Apple" title="Apple">
</a>
</p>
<h5>Autor</h5>
<p>&COPY;Cristina Martínez - acmartinez96.blogspot.com</p>
</div>
</div>
</div>
</footer>
<!--Fin de pie de página-->
</body>
</html>
/FOOTER/
#footer h5
display: block;
background: url(../img/pxgray.png), white;
height: 55px;
letter-spacing: 2px;
text-align: center;
font-family: "BebasNeue";
font-size: 40px;
line-height: 55px;
color: black;
border-radius: 5px;
margin-bottom: 15px;
#footer ul
text-align: left;
margin: 20px;
font-size: 25px;
#footer ul li
margin-top: 10px;
padding: 5px;
border-bottom: 1px solid #cccccc;
#footer ul li a
display: block;
height: 40px;
#footer iframe
width: 100%;
height: 300px;
margin-top: 10px;
border-radius: 5px;
box-shadow: 0x 0px 5px grey;
border: 5px solid white;
}
#footer img
margin-bottom: 15px;
#footer #browsers img{
width: 45px;
Thanks!
Try to use flexbox it's very helpful.
the rendering you request can be done simply this way
<div class="flex">
<div class="ll">Menu</div>
<div class="ll">Map</div>
<div class="ll">Footer</div>
</div>
div.ll {
background: #fff;
margin: 20 auto;
width: 200px;
padding: 50px;
text-align: center;
}
div.flex {
display: flex;
}
You can test it by using sandbox
Instead of a footer, try creating a <div> or <section> and align that to the right.

CSS Padding(?) on inline block top messing up my div content

https://codepen.io/markoslk/pen/qNgWGN
h1 {
color: white;
font-size: 90px;
text-align: center;
width: 950px;
height: 100px;
margin: auto;
margin-top: 20px;
border-radius: 5px;
background-color: darkblue;
}
#slogan {
font-size: 40px;
text-align: center;
margin: auto;
margin-top: -3px;
font-family: Agency FB;
width: 940px;
height: 50px;
background-color: white;
border: 5px solid darkblue;
}
#table {
display: inline-block;
width: 225px;
height: 170px;
margin-top: 59.25px;
margin-left: 59.25px;
text-align: left;
background-color: #c0c0c0;
color: white;
border-radius: 5px;
}
.content {
text-align: center;
border-radius: 5px;
background-color: darkblue;
}
ul {
font-family: Georgia;
text-decoration: none;
list-style-type: none;
padding: 0px;
margin: 0px;
margin-top: -10px;
margin-left: 10px;
}
a {
text-decoration: none;
color: white;
}
.div {
width: 940px;
height: 525px;
margin: auto;
border-radius: 5px;
background-color: white;
border: 5px solid darkblue;
border-top-left-radius: 0px;
border-top-right-radius: 0px;
}
img {
width: 25px;
height: 25px;
padding-right: 10px;
}
<h1>NBA 2016</h1>
<p id="slogan"><i>Basketball never stops</i>
</p>
<div class="div">
<div id="table">
<h2 class="content">Atlantic</h2>
<ul>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/bos.png&h=25&w=25">Boston Celtics
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/bkn.png&h=25&w=25">Brooklyn Nets
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/ny.png&h=25&w=25">New York Knicks
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/phi.png&h=25&w=25">Philadelphia 76ers
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/tor.png&h=25&w=25">Toronto Raptors
</li>
</ul>
</div>
<div id="table">
<h2 class="content">Central</h2>
<ul>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/chi.png&h=25&w=25">Chicago Bulls
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/cle.png&h=25&w=25">Cleveland Cavaliers
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/det.png&h=25&w=25">Detroit Pistons
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/ind.png&h=25&w=25">Indiana Pacers
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/mil.png&h=25&w=25">Milwaukee Bucks
</li>
</ul>
</div>
<div id="table">
<h2 class="content">Northwest</h2>
<ul>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/den.png&h=25&w=25">Denver Nuggets
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/min.png&h=25&w=25">Minnesota Timberwolves
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/okc.png&h=25&w=25">Oklahoma City Thunder
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/por.png&h=25&w=25">Portland Trail Blazers
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/utah.png&h=25&w=25">Utah Jazz
</li>
</ul>
</div>
<div id="table">
<h2 class="content">Pacific</h2>
<ul>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/gsw.png&h=25&w=25">Golden State Warriors
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/lac.png&h=25&w=25">LA Clippers
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/lal.png&h=25&w=25">Los Angeles Lakers
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/pho.png&h=25&w=25">Phoenix Suns
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/sac.png&h=25&w=25">Sacramento Kings
</li>
</ul>
</div>
<div id="table">
<h2 class="content">Southeast</h2>
<ul>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/atl.png&h=25&w=25">Atlanta Hawks
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/cha.png&h=25&w=25">Charlotte Hornets
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/mia.png&h=25&w=25">Miami Heat
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/orl.png&h=25&w=25">Orlando Magic
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/was.png&h=25&w=25">Washington Wizards
</li>
</ul>
</div>
<div id="table">
<h2 class="content">Southwest</h2>
<ul>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/dal.png&h=25&w=25">Dallas Mavericks
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/hou.png&h=25&w=25">Houston Rockets
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/mem.png&h=25&w=25">Memphis Grizzlies
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/no.png&h=25&w=25">New Orleans Pelicans
</li>
<li>
<img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/sas.png&h=25&w=25">San Antonio Spurs
</li>
</ul>
</div>
</div>
Rest of the code is on codepen link. There seems to be some padding or something on the top of my divs. There wasn't one until I used display: inline-block. I can fit in the title of each div but that would have to be done with setting the adequate margin to it. But I don't want to move gray area,I want it to be where it is because I tried to center it as much as possible. (Is there more efficient way to do it? I did it by calculating margins and dividing. Basically I want all margins to be the same (bottom,top,right,left)) I want title,along with the list to go a bit up to fit the gray area perfectly. How can I do it?
There is a default margin on the h2 element.
When you remove the top margin from the h2 element, you get the desired result.
CSS
h2 {
margin-top: 0;
}
Codepen link
The issue you're facing is not caused by a padding, but a margin-top in your h2 element that exists by default. You can use the following CSS code to alleviate it:
.content {
margin-top: 0;
}
Codepen: → here.
Snippet:
h1 {
color: white;
font-size: 90px;
text-align: center;
width: 950px;
height: 100px;
margin: auto;
margin-top: 20px;
border-radius: 5px;
background-color: darkblue;
}
#slogan {
font-size: 40px;
text-align: center;
margin: auto;
margin-top: -3px;
font-family: Agency FB;
width: 940px;
height: 50px;
background-color: white;
border: 5px solid darkblue;
}
#table {
display: inline-block;
width: 225px;
height: 170px;
margin-top: 59.25px;
margin-left: 59.25px;
text-align: left;
background-color: #c0c0c0;
color: white;
border-radius: 5px;
}
.content {
margin-top:0;
text-align: center;
border-radius: 5px;
background-color: darkblue;
}
ul {
font-family: Georgia;
text-decoration: none;
list-style-type: none;
padding: 0px;
margin: 0px;
margin-top: -10px;
margin-left: 10px;
}
a {
text-decoration: none;
color: white;
}
.div {
width: 940px;
height: 525px;
margin: auto;
border-radius: 5px;
background-color: white;
border: 5px solid darkblue;
border-top-left-radius: 0px;
border-top-right-radius: 0px;
}
img {
width: 25px;
height: 25px;
padding-right: 10px;
}
</head>
<body>
<h1>NBA 2016</h1>
<p id="slogan"><i>Basketball never stops</i></p>
<div class="div">
<div id="table">
<h2 class="content">Atlantic</h2>
<ul><li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/bos.png&h=25&w=25">Boston Celtics</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/bkn.png&h=25&w=25">Brooklyn Nets</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/ny.png&h=25&w=25">New York Knicks</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/phi.png&h=25&w=25">Philadelphia 76ers</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/tor.png&h=25&w=25">Toronto Raptors</li></ul>
</div>
<div id="table">
<h2 class="content">Central</h2>
<ul><li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/chi.png&h=25&w=25">Chicago Bulls</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/cle.png&h=25&w=25">Cleveland Cavaliers</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/det.png&h=25&w=25">Detroit Pistons</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/ind.png&h=25&w=25">Indiana Pacers</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/mil.png&h=25&w=25">Milwaukee Bucks</li></ul>
</div>
<div id="table">
<h2 class="content">Northwest</h2>
<ul><li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/den.png&h=25&w=25">Denver Nuggets</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/min.png&h=25&w=25">Minnesota Timberwolves</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/okc.png&h=25&w=25">Oklahoma City Thunder</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/por.png&h=25&w=25">Portland Trail Blazers</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/utah.png&h=25&w=25">Utah Jazz</li></ul>
</div>
<div id="table">
<h2 class="content">Pacific</h2>
<ul><li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/gsw.png&h=25&w=25">Golden State Warriors</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/lac.png&h=25&w=25">LA Clippers</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/lal.png&h=25&w=25">Los Angeles Lakers</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/pho.png&h=25&w=25">Phoenix Suns</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/sac.png&h=25&w=25">Sacramento Kings</li></ul>
</div>
<div id="table">
<h2 class="content">Southeast</h2>
<ul><li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/atl.png&h=25&w=25">Atlanta Hawks</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/cha.png&h=25&w=25">Charlotte Hornets</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/mia.png&h=25&w=25">Miami Heat</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/orl.png&h=25&w=25">Orlando Magic</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/was.png&h=25&w=25">Washington Wizards</li></ul>
</div>
<div id="table">
<h2 class="content">Southwest</h2>
<ul><li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/dal.png&h=25&w=25">Dallas Mavericks</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/hou.png&h=25&w=25">Houston Rockets</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/mem.png&h=25&w=25">Memphis Grizzlies</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/no.png&h=25&w=25">New Orleans Pelicans</li>
<li><img style="vertical-align:middle" src="http://a.espncdn.com/combiner/i?img=/i/teamlogos/nba/500/sas.png&h=25&w=25">San Antonio Spurs</li></ul>
</div>
</div>
</body>
</html>
You just need to remove the margin from the content header. You can target a specific margin using the top,left, right or bottom. In this case you need to target the margin-top of the h2 tag.
.content {
text-align:center;
border-radius:5px;
background-color:darkblue;
margin-top:0; /*This is the added property*/
}
Is this what you're looking for? https://codepen.io/anon/pen/ZOwEGE
Also it's a good idea to use the web inspector (F12) in the browser to find out whats affecting your elements.
If I understand you well, you want something lie this:
https://codepen.io/bra1N/pen/YWBzXx
CSS:
h1 {
color: white;
font-size: 90px;
text-align: center;
width: 1048px;
height: 100px;
margin: auto;
margin-top: 20px;
border-radius: 5px;
background-color: darkblue;
}
#slogan {
font-size: 40px;
text-align: center;
margin: auto;
margin-top: -3px;
font-family: Agency FB;
width: 1040px;
height: 50px;
background-color: white;
border: 5px solid darkblue;
}
#table {
display: inline-block;
width: 225px;
height: 170px;
margin-top: 59.25px;
margin-left: 59.25px;
text-align: left;
background-color: #c0c0c0;
color: white;
padding: 20px;
border-radius: 5px;
}
.content {
text-align: center;
border-radius: 5px;
background-color: darkblue;
}
ul {
font-family: Georgia;
text-decoration: none;
list-style-type: none;
padding: 0px;
margin: 0px;
margin-top: -10px;
margin-left: 10px;
}
a {
text-decoration: none;
color: white;
}
.div {
width: 1040px;
height: 525px;
margin: auto;
border-radius: 5px;
background-color: white;
border: 5px solid darkblue;
border-top-left-radius: 0px;
border-top-right-radius: 0px;
}
img {
width: 25px;
height: 25px;
padding-right: 10px;
}

anchor tag link should be available only inside red bordered area

I am trying to clean up the way my anchors work, I want anchor tag link should be available only inside the red bordered area.
In other words the anchor tag link should be available on div where .categoryArea class is applied, and mouse pointer should be normal outside of the said area.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta charset="utf-8" />
<style type="text/css">
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
color: #666;
}
.content {
width: 100%;
max-width: 640px;
border: 1px solid #eee;
margin: 0 auto;
}
.categoryArea {
width: 100px;
height: 130px;
margin: 4px auto 4px auto;
background-color: white;
border: 2px solid red;
padding: 4px;
}
.categoryArea:hover {
box-shadow: 0px 0px 5px #888888;
}
.categoryIcon {
width: 100px;
height: 88px;
background-color: gold;
margin: 0 auto;
}
.categoryName {
text-align: center;
font-size: 0.8em;
line-height: 1.2em;
height: 2.4em;
color: #2f2f2f;
margin: 2px 0px 0px 0px;
overflow: hidden;
}
.category-selector {
display: table;
width: 100%;
background-color: cyan;
margin: 0 auto;
}
.category-selector a {
text-decoration: none;
color: inherit;
}
ul {
list-style:none;
margin: 0px;
padding: 0px;
}
.category {
display: block;
float: left;
width: 50%;
min-width: 125px;
margin: 0 auto;
background-color: beige;
}
</style>
</head>
<body>
<div class="content">
<h3>Some text here..</h3>
<nav class="category-selector">
<ul>
<li class="category">
<a href="/aaaaaa">
<div class="categoryArea">
<div class="categoryIcon">
Icon
</div>
<p class=categoryName>aaaaaa</p>
</div>
</a>
</li>
<li class="category">
<a href="/bbbbbb">
<div class="categoryArea">
<div class="categoryIcon">
Icon
</div>
<p class=categoryName>bbbbbb</p>
</div>
</a>
</li>
<li class="category">
<a href="/cccccc">
<div class="categoryArea">
<div class="categoryIcon">
Icon
</div>
<p class=categoryName>cccccc</p>
</div>
</a>
</li>
<li class="category">
<a href="/dddddd">
<div class="categoryArea">
<div class="categoryIcon">
Icon
</div>
<p class=categoryName>dddddd</p>
</div>
</a>
</li>
<li class="category">
<a href="/eeeeee">
<div class="categoryArea">
<div class="categoryIcon">
Icon
</div>
<p class=categoryName>eeeeee</p>
</div>
</a>
</li>
<li class="category">
<a href="/ffffff">
<div class="categoryArea">
<div class="categoryIcon">
Icon
</div>
<p class=categoryName>ffffff</p>
</div>
</a>
</li>
</ul>
</nav>
</div>
</body>
</html>
https://jsfiddle.net/uvsrtpfu/
Removed the class form div inside <a> tag and added it to <a> tag and set it to block.
https://jsfiddle.net/uvsrtpfu/2/
You should use the anchor tag inside the div. This works:
<li class="category">
<div class="categoryArea">
<a href="/aaaaaa">
<div class="categoryIcon">
Icon
</div>
<p class=categoryName>aaaaaa</p>
</a>
</div>
</li>
You have to give display display:inline-block; to the a element and then give text-align:center; to the .category.
Jsfiddle

Removing space between menu and image

Does anyone know how I can remove the space between the top of my menu and the bottom of the image on top of the page. I tried to do it with margin and padding. But that didn't work.
This is a picture of the result I get now
#charset "UTF-8";
body {
background-color: #ADF1F5;
}
html,
body {
margin: 0;
padding: 0;
}
#Anouk {
text-align: center;
margin: 0 auto;
padding: 0;
}
#header {
height: 80px;
background: #000000;
}
li {
display: block;
float: left;
}
li a {
color: #FFFFFF;
height: 80px;
}
#contact {
float: right;
}
<div id="Anouk">
<img src="logo/Hout.png" width="1000px" alt="Logo" />
</div>
<div id="header">
<div id="menu">
<!--Home-->
<li id="home">
<a href="index.html">
<img src="Iconen/Home.png" height="80px" alt="home" onmouseover="this.src='Iconen/Home2.png'" onmouseout="this.src='Iconen/Home.png'" />
</a>
</li>
<!--Over Mij-->
<li id="over">
<a href="over.html">
<img src="Iconen/Over.png" height="80px" alt="home" onmouseover="this.src='Iconen/Over2.png'" onmouseout="this.src='Iconen/Over.png'" />
</a>
</li>
<!--Portfolio-->
<li id="portfolio">
<a href="portfolio.html">
<img src="Iconen/Portfolio.png" height="80px" alt="home" onmouseover="this.src='Iconen/Portfolio2.png'" onmouseout="this.src='Iconen/Portfolio.png'" />
</a>
</li>
<!--Contact-->
<li id="contact">
<a href="contact.html">
<img src="Iconen/Contact.png" height="80px" alt="home" onmouseover="this.src='Iconen/Contact2.png'" onmouseout="this.src='Iconen/Contact.png'" />
</a>
</li>
</div>
</div>
Try to add display:block to your top most image.
#Anouk img{
display: block;
}
Here is a solution: https://jsfiddle.net/egjbmp1u/
For your #header style you need to add:
position: relative;
float: left;
width: 100%;
Also, #Anouk style should look like this:
#Anouk {
display: flex;
text-align: center;
padding: 0;
}
#Anouk img {
margin: 0 auto;
}

align images in "li" tags

I have thumbnails of images on my site. This is how it looks:
Let's consider the second row. There are two images( always two images in row) and I want to make that the second picture was aligned to the right.
How can I do this?
This is example what I want:
This is the html code:
<div class="navigation_container">
<div id="dpthumbs0" class="navigation">
<ul style="opacity: 1;" class="thumbs">
<li class="selected" style="opacity: 1;"><a rel="history" title="image" class="thumb" href="#1">
<img height="60px" style="height: 58px; max-width: 79px;" src="/Image/GetImage?imageName=571437e8-ecfc-46f4-a14f-a645428fae46-pic_172.jpg">
</a></li>
<li class="" style="opacity: 1;"><a rel="history" title="image" class="thumb" href="#2">
<img height="60px" style="height: 58px; max-width: 79px;" src="/Image/GetImage?imageName=5ef5e802-916a-4ede-af11-c90274c63218-pic_176.jpg">
</a></li>
<li class="" style="opacity: 1;"><a rel="history" title="image" class="thumb" href="#3">
<img height="60px" style="height: 58px; max-width: 79px;" src="/Image/GetImage?imageName=fa6f5671-b9f6-48e6-a822-cea83424643c-pic_178.jpg">
</a></li>
<li class="" style="opacity: 1;"><a rel="history" title="image" class="thumb" href="#4">
<img height="60px" style="height: 58px; max-width: 79px;" src="/Image/GetImage?imageName=10b628ed-387e-43b5-908b-80b92efb7d2b-pic_180.jpg">
</a></li>
</ul>
<!-- .thumbs-->
</div>
<!-- .navigation-->
</div>
This is all css:
.navigation_container {
float: right;
margin: 15px 0;
padding: 30px 0;
position: relative;
}
.navigation {
height: 275px;
overflow: hidden;
width: 175px;
}
.slider .thumbs {
width: 175px;
}
.thumbs li {
float: left;
padding: 4px 0 4px 8px;
}
.thumbs li img {
border: 1px solid #424D55;
height: 58px;
max-width: 79px;
}
Thanks.
You have to create two classes & define like that:
CSS
.left{
float:left;
clear:left;
}
.right{
float:right;
clear:right;
}
HTML
<li class="left"></li>
<li class="right"></li>
<li class="left"></li>
<li class="right"></li>
Add this to your CSS code
.thumbs li.alt {
float: right;
padding: 4px 8px 4px 0px;
}
Add class .alt to every 2nd li, use your template engine's for loop or something similar :). This way in the future if you decide to turn off the right alignment, you just have to modify 1 css class.
<li class="">...</li>
<li class="alt">...</li>
neither of these css rules change the html embedded picture alignment to fall to right side inside
<ul>
tags...