gpt4 book ai didi

html - 如何使用 CSS 去除图像下方多余的空白区域

转载 作者:行者123 更新时间:2023-11-28 07:11:48 31 4
gpt4 key购买 nike

/* Typography */

.header {font-family: "futura-pt", Arial, Helvetica, sans-serif; font-weight: 700; font-size: 1.0em; margin: 0; padding: 0; text-transform: uppercase; letter-spacing: 0.1em;}
p {font-family: "futura-pt", Arial, Helvetica, sans-serif; font-weight: 400; font-size: 1.0em; margin: 0; padding: 0; text-transform: uppercase; letter-spacing: 0.1em;}
/* Sizes */

.large-5 {font-size: 5.0em;}
.large-4 {font-size: 4.0em;}
.large-3 {font-size: 3.0em;}
.large-25 {font-size: 2.5em;}
.large-2 {font-size: 1.5em;}
.large-15 {font-size: 1.3em;}

@media screen and (min-width: 768px) {
.large-5 {font-size: 5.0em;}
.large-4 {font-size: 4.0em;}
.large-3 {font-size: 3.0em;}
.large-25 {font-size: 2.5em;}
.large-2 {font-size: 2.0em;}
.large-15 {font-size: 1.5em;}
}

/* Colours */

.white {color: #fff;}
.black {color: #000;}

/* Spacing */

.padding-top {padding-top: 2em;}
.padding-top-double {padding-top: 2em;}
.padding-top-triple {padding-top: 1em;}
.padding-bottom {padding-bottom: 1em;}

/* Links */

a:link, a:visited, a:active {color: #fff; text-decoration: none;}
a:hover {color: #fff; text-decoration: underline;}

/* General */

body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
text-align: center;
background: #fff;
}

*, *:before, *:after {
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
}

/* Structure */

.container {
background-image: url("img/hd-sunset-river-HD-1200x1920.jpg");
background-size: cover;
width: 100%;
height: 100%;
border: 5px solid #fff;

}


.content {
width: 100%;
max-width: 500px;
position: relative;
top: 50%;
height: 1200px;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
margin: 0 auto;

}

.content img {
max-width: 100%;

}

my-email::after {
content: attr(data-domain);
}

my-email::before {
content: attr(data-user) "\0040";
}

这是我的 CSS 代码。在询问 Stack Overflow 上的人之前,我曾尝试研究答案,我尝试过 {display: block;} 和其他人,但我没有运气。我希望我在代码中犯了一个错误,因为这引起了一些头痛,因为我仍在学习 CSS 和 HTML。

<!doctype html>

<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<title>Coming Soon</title>
<link href="css/Main.css" rel="stylesheet">

</head>

<body>


<div class="container">
<img src="img/hd-sunset-river-HD-1200x1920.jpg" width="1900" height="900">
</div>
<section class="content">
<img src="img/logo.png">
<img src="img/line.png">
<p class="header large-2 white padding-top-triple">Coming This Fall 2015</p>
<p class="white padding-top"><span class="header">Email: </span><a href="mailto:Jethwa96@hotmail.co.uk"><my-email data-user="Jethwa" data-domain="jedesigns.uk"></my-email></a></p>
</section>





</body>
</html>

最佳答案

问题是您将背景作为图像 block 放在单独的 div 中,然后尝试将 divsection 对齐.这有点倒退和由内而外。

我建议改为设置 section 的背景,然后将内部内容包装在 div 中,您可以轻松地将其放置在 section

带背景的部分,内部 div 包装内容:

<section class="content">

<div style="width:500px;
margin:0 auto;
top:25%;
position:relative">

<img src="http://jedesigns.uk/img/logo.png">
<img src="http://jedesigns.uk/img/line.png">
<p class="header large-2 white padding-top-triple">Coming This Fall 2015</p>
<p class="white padding-top"><span class="header">Email: </span><a href="mailto:Jethwa96@hotmail.co.uk"><my-email data-user="Jethwa" data-domain="jedesigns.uk"></my-email></a></p>

</div>

</section>

然后对于您的 section.content CSS,更改为:

.content{
width: 100%;
position: relative;
height: 1200px;
margin: 0 auto;
background:url(http://jedesigns.uk/img/hd-sunset-river-HD-1200x1920.jpg) no-repeat;
}

这是 jsFiddle:http://jsfiddle.net/z22hrvk9/

关于html - 如何使用 CSS 去除图像下方多余的空白区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32592505/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com