Im in the process of making a sort of meme/troll website that I am messing around with and kind of applying everything i learned so far in HTML/CSS, but I have come across a problem that I can not figure out. In the picture below there is a block element with "Article" in it and then a picture above that. But between the below space and the picture at the top there is a whitespace between the two. Ive tried the following: using * to make all the margins 0 on the page, getting rid of the margin on the top pic and the bottom section but both seem to do nothing. Is this just something I have to deal with or is there a way around it?
https://i.stack.imgur.com/l45oQ.png
code below:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style type="text/css">
*{
margin: 0;
}
#header{
width: 100%;
height: 18rem;
margin: 0;
}
.dropdown1{
display: none;
}
.navbar ul li:hover .dropdown1{
display: inline-flex;
}
.navbar{
background-color: #7E7B7B;
margin: 0;
}
</style>
</head>
<body>
<img id="header" src="http://tencowchick.com/wp-content/uploads/2011/03/2011-03-09-001.jpg" alt="header">
<div >
<ul>
<li>
<a href="#">Artices</a>
<div >
<ul>
<li>John Cena Dies After Tragic Accident</li>
<li>PewDiePie Dies After T-Series Assasination</li>
<li>Will Smith's Wife Kills Him After Grammy's Incident!</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
</body>
</html>```
[![pictare][1]][1]
[1]: https://i.stack.imgur.com/l45oQ.png
CodePudding user response:
add display:block to your image
img{
display:block;
}
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style type="text/css">
*{
margin: 0;
}
#header{
width: 100%;
height: 18rem;
margin: 0;
}
.dropdown1{
display: none;
}
.navbar ul li:hover .dropdown1{
display: inline-flex;
}
.navbar{
background-color: #7E7B7B;
margin: 0;
}
</style>
</head>
<body>
<img id="header" src="http://tencowchick.com/wp-content/uploads/2011/03/2011-03-09-001.jpg" alt="header"><div >
<ul>
<li>
<a href="#">Artices</a>
<div >
<ul>
<li>John Cena Dies After Tragic Accident</li>
<li>PewDiePie Dies After T-Series Assasination</li>
<li>Will Smith's Wife Kills Him After Grammy's Incident!</li>
</ul>
</div>
</li>
</ul>
</div>
</body>
</html>
CodePudding user response:
*{
margin: 0;
}
#header{
width: 100%;
height: 18rem;
margin: 0;
display:block;
}
.dropdown1{
display: none;
}
.navbar ul li:hover .dropdown1{
display: inline-flex;
}
.navbar{
background-color: #7E7B7B;
margin: 0;
}
<body>
<img id="header" src="http://tencowchick.com/wp-content/uploads/2011/03/2011-03-09-001.jpg" alt="header">
<div >
<ul>
<li>
<a href="#">Artices</a>
<div >
<ul>
<li>John Cena Dies After Tragic Accident</li>
<li>PewDiePie Dies After T-Series Assasination</li>
<li>Will Smith's Wife Kills Him After Grammy's Incident!</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
CodePudding user response:
The size of the space between your div elements are determined by font-size. You can create use the following CSS code to solve your problem:
#noSpace {
font-size: 0;
}
#noSpace > div {
font-size: /* Whatever you want the font-size to be */;
}
After this, you can just put the div elements inside a div like this:
<div id="noSpace">
<div>Lorem Ipsum</div>
</div>