我只想放大背景图像,但是它覆盖了标题,overflow: hidden
不起作用
https://jsfiddle.net/space2froggy/7t95nvLy/2/这是我的代码。
HTML
<header>
<div class="logo">
<img src="resources/logo/logo.svg" class="logo-img" alt="Logo">
</div>
<div class="main-nav">
<ul>
<li><a href="#">About me</a></li>
<li><a href="#">Relationships</a></li>
<li><a href="#">Requirements</a></li>
<li><a href="#">Users</a></li>
<li><a href="#">Sign Up</a></li>
</ul>
</div>
<div class="settings">
<div class="user-data">
<h6>Superstar</h6>
<p>superstar@gmail.com</p>
</div>
<img src="resources/img/user-superstar-2x.jpg" class="photo-small" alt="User Photo">
<img src="resources/icons/sign-out.svg" alt="Sign Out" class="sign-out">
</div>
</header>
<section class="board">
<h1>Test assignment for Frontend Developer Position</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<a href="#" class="btn btn-full">Sign Up</a>
</section>
CSS
.board {
background-image: url(img/bg-1.jpg);
background-size: cover;
background-position: center;
transform: scale(2);
overflow: hidden;
}
答案 0 :(得分:0)
删除变换:scale(2);从CSS然后显示正常。
.board {
background-image: url('https://cdn.pixabay.com/photo/2017/08/30/01/05/milky-way-2695569_960_720.jpg');
background-size: cover;
background-position: center;
overflow: hidden;
}
{
margin: 0;
padding: 0;
box-sizing: border-box; /* always at start */
}
html {
font-family: 'Lato', 'Arial', sans-serif;
font-size: 20px;
text-rendering: optimizeLegibility; /*IMP!!!*/
line-height: 145%;
max-width: 2560px;
}
header {
max-width: 1140px;
margin: 15px auto;
}
header > * {
display: inline-block;
}
header a {
text-decoration: none;
color: #171717;
}
.logo {
width: 15%;
}
.logo-img {
width: 150px;
height: auto;
}
.main-nav {
font-size: 15px;
margin-left: 10%;
}
.main-nav ul li {
float: left;
list-style: none;
padding: 0 15px;
}
.settings {
float: right;
line-height: 80%;
}
.settings > * { /* to all ONLY child els */
float: left;
display: inline-block;
}
.photo-small {
width: 40px;
height: auto;
border-radius: 50%;
}
.user-data {
padding: 0 10px;
}
.settings h6 {
float: right;
}
.settings p {
font-size: 12px;
color: #a0a0a0;
}
.photo-small {
margin: -5px 5px;
}
.sign-out {
margin: 5px 10px;
}
/*//////////////////////////*/
/*////////---BOARD---////////*/
/*//////////////////////////*/
h1 {
margin: 0;
}
<header>
<div class="logo">
<img src="resources/logo/logo.svg" class="logo-img" alt="Logo">
</div>
<div class="main-nav">
<ul>
<li><a href="#">About me</a></li>
<li><a href="#">Relationships</a></li>
<li><a href="#">Requirements</a></li>
<li><a href="#">Users</a></li>
<li><a href="#">Sign Up</a></li>
</ul>
</div>
<div class="settings">
<div class="user-data">
<h6>Superstar</h6>
<p>superstar@gmail.com</p>
</div>
<img src="resources/img/user-superstar-2x.jpg" class="photo-small" alt="User Photo">
<img src="resources/icons/sign-out.svg" alt="Sign Out" class="sign-out">
</div>
</header>
<section class="board">
<h1>Test assignment for Frontend Developer Position</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<a href="#" class="btn btn-full">Sign Up</a>
</section>