我目前正在编写一个小的登陆页面。我试图在CSS中添加一个背景图像,但它只是不起作用。
我的CSS:
@import url('https://fonts.googleapis.com/css?family=Oswald');
@import url('https://fonts.googleapis.com/css?family=Robo+Condensed');
html, body {
margin: 0;
padding: 0;
height: 100%
width: 100%
}
.intro {
height: 100%;
width: 100%;
margin: auto;
background: url(pexelsphoto.jpg) no-repeat 50% 50%;
}
我的HTML:
<html>
<head>
<title>First Server</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<section class="intro">
<div class="inner">
<div class="content">
<h1>JORDAN'S SERVER</h1></div>
<a class="button" href="#">Click Me</a>
<div>
<img src="pexelsphoto.jpg">
</div>
</div>
</section>
<p>First full web server design made in July of 2018. This all holds my
random stuff while I learn to code.</p>
</body>
</html>
发布于 2018-07-23 14:38:16
把你的背景像这样放进body里:
body {
background: url("pexelsphoto.jpg") no-repeat 50% 50%;
}
html, body {
margin: 0;
padding: 0;
height: 100%
width: 100%
}
.intro {
height: 100%;
width: 100%;
margin: auto;
}
发布于 2018-07-23 15:10:42
. Intro {
height:100%;
width: 100%;
margin auto;
background: url("pexelsphoto.jpg") no-repeat 50% 50%;
}
将双引号添加到图像名称中。
https://stackoverflow.com/questions/-100005629
复制相似问题