我的网站上有一张图片,顶部有大约50px的额外空白区域。我试过padding none和margin none,显示块但没有一个工作。 Here is a working jsfiddle of it. 这是我的HTML
h1 {
font-size: 100px;
color: white;
text-align: center;
opacity: none;
font-family: 'Noto Sans', sans-serif;
}
p {
font-family: 'Roboto Condensed', sans-serif;
font-size: 70px;
color: black;
text-align: center;
}
.rotate {
float: left;
-webkit-transform: rotate(180deg) 2s;
transform: rotate(180deg) 2s;
transition: all 2s ease;
transition-delay: 0.4s;
}
.rotate:hover {
-webkit-transform: rotateZ(-360deg);
-ms-transform: rotateZ(-360deg);
transform: rotateZ(-360deg);
}
.container {
overflow: hidden;
font-family: 'Roboto Condensed', sans-serif;
position: static;
z-index: 150;
margin-bottom: -80px;
}
.container a {
float: right;
font-size: 20px;
color: black;
text-align: center;
padding: 40px 70px;
text-decoration: none;
transition: background 1s;
}
.dropdown {
float: right;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 20px;
border: none;
outline: white;
color: black;
padding: 40px 70px;
background-color: inherit;
font-family: 'Roboto Condensed', sans-serif;
transition: background 1s;
}
.container a:hover, .dropdown:hover .dropbtn {
background-color: lightgreen;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
border-right: 1px solid #bbb;
}
.dropdown-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
font-size: 18px;
}
.dropdown-content a:hover {
background-color: #ddd;
border-right: 1px solid #bbb;
}
.dropdown:hover .dropdown-content {
display: block;
}
<body>
<div class="active">
<div id="background">
<div class="opacity">
<div class="container">
<div class="rotate">
<img class="chiz" src="kkk.png" alt="Vortex Games">
</div>
<a href="index.html">Home</a>
<a href="about.html">About</a>
<a href="FAQ.html">FAQ</a>
<a href="games.html">Games</a>
<div class="dropdown">
<button class="dropbtn"
onclick="window.location.href='store.html'">Store</button>
<div class="dropdown-content">
<a href="wall.html">Powerups</a>
<a href="store.html">Coins</a>
</div>
</div>
</div>
</div>
<p class="title">
We're a top-of-the-line high tech <br>game company
<br>
<span style="color:white;font-size:20px;padding:none;display:inline-
block;">
<span style="color:red;font-size:100px;padding-top:none;">
–<br></span>Driven by passion. Always at our best.</span>
</p>
<!--the background div-->
</div>
<div class="creative">
<img src="cree.jpg" align="abstop">
</div>
CSS
任何帮助都将不胜感激。
由于
答案 0 :(得分:3)
您需要在css中添加*{margin:0;padding: 0;}
这个。因为它不仅仅是关于你的图像属性。你有更多的元素有一些默认的css属性,这可能会影响你的HTML。 *制作通用标签
*{
margin:0;padding: 0;
}
.creative {
padding-top: none;
}
img {
display: block;
}
body {
/*body:0;*/
}
#background {
background: url('https://sellorelse.ogilvy.com/wp-content/uploads/2016/06/creativity_technology.png');
background-position:center top;
}
h1 {
font-size: 100px;
color: white;
text-align: center;
opacity: none;
font-family: 'Noto Sans', sans-serif;
}
p {
font-family: 'Roboto Condensed', sans-serif;
font-size: 70px;
color: black;
text-align: center;
}
.rotate {
float: left;
-webkit-transform: rotate(180deg) 2s;
transform: rotate(180deg) 2s;
transition: all 2s ease;
transition-delay: 0.4s;
}
.rotate:hover {
-webkit-transform: rotateZ(-360deg);
-ms-transform: rotateZ(-360deg);
transform: rotateZ(-360deg);
}
.container {
overflow: hidden;
font-family: 'Roboto Condensed', sans-serif;
position: static;
z-index: 150;
margin-bottom: -80px;
}
.container a {
float: right;
font-size: 20px;
color: black;
text-align: center;
padding: 40px 70px;
text-decoration: none;
transition: background 1s;
}
.dropdown {
float: right;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 20px;
border: none;
outline: white;
color: black;
padding: 40px 70px;
background-color: inherit;
font-family: 'Roboto Condensed', sans-serif;
transition: background 1s;
}
.container a:hover, .dropdown:hover .dropbtn {
background-color: lightgreen;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
border-right: 1px solid #bbb;
}
.dropdown-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
font-size: 18px;
}
.dropdown-content a:hover {
background-color: #ddd;
border-right: 1px solid #bbb;
}
.dropdown:hover .dropdown-content {
display: block;
}
&#13;
<div class="active">
<div id="background">
<div class="opacity">
<div class="container">
<div class="rotate">
<img class="chiz" src="kkk.png" alt="Vortex Games">
</div>
<a href="index.html">Home</a>
<a href="about.html">About</a>
<a href="FAQ.html">FAQ</a>
<a href="games.html">Games</a>
<div class="dropdown">
<button class="dropbtn" onclick="window.location.href='store.html'">Store</button>
<div class="dropdown-content">
<a href="wall.html">Powerups</a>
<a href="store.html">Coins</a>
</div>
</div>
</div>
</div>
<p class="title">
We're a top-of-the-line high tech <br>game company
<br>
<span style="color:white;font-size:20px;padding:none;display:inline-block;">
<span style="color:red;font-size:100px;padding-top:none;">
–<br></span>Driven by passion. Always at our best.</span>
</p>
<!--the background div-->
</div>
<div class="creative">
<img src="http://drwillsparks.com/wp-content/uploads/2017/02/creativity.jpg" align="abstop">
</div>
&#13;
答案 1 :(得分:0)
由于p元素上的某些浏览器预设边距而发生。你可以用它删除它:
p.title {
margin-bottom: 0px;
}
答案 2 :(得分:0)
默认情况下,html页面有边距值。添加它以避免这些空格
* {
margin: 0;
padding: 0;
}