- 本套教程学习来自视频:https://www.bilibili.com/video/BV1n94y1o7yS/?p=7&spm_id_from=pageDriver&vd_source=b79be8283df9418cb45941cc0bd583c6
案例
实现效果图
代码
HTML:
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://fonts.googleapis.com/css?family=Lato:100,300,400,700,900" rel="stylesheet"><link rel="stylesheet" href="css/icon-font.css"><link rel="stylesheet" href="css/style.css"><link rel="shortcut icon" type="image/png" href="img/favicon.png"><title>Natours | Exciting tours for adventurous people</title></head><body><header class="header"><div class="logo-box"><img src="img/logo-white.png" alt="Logo" class="logo"></div><div class="text-box"><h1 class="heading-primary"><span class="heading-primary-main">outdoors</span><span class="heading-primary-sub">is where life happiness</span></h1></div></header></body>
</html>
CSS:
* {margin: 0;padding: 0;box-sizing: border-box;
}body {font-family: "Lato", sans-serif;font-weight: 400;font-size: 16px;line-height: 1.7;color: #777;padding: 30px;
}.header {height: 95vh;background-image: linear-gradient(to right bottom, rgba(128, 214, 113, 0.804), rgba(39, 180, 133, 0.8)), url(../img/hero.jpg);background-size: cover;background-position: top;clip-path: polygon(0 0, 100% 0, 100% 80%, 0 100%);position: relative;
}.logo-box {position: absolute;top: 40px;left: 40px;
}.logo {width: 80px;
}.text-box {position: absolute;left: 50%;top: 40%;transform: translate(-50%, -50%);
}.heading-primary {color: #fff;text-transform: uppercase;
}.heading-primary-main {display: block;font-size: 60px;font-weight: 700;letter-spacing: 30px;
}.heading-primary-sub {display: block;font-size: 16px;font-weight: 700;letter-spacing: 15.7px;
}
相关知识
clip-path
使用裁剪方式创建元素的可显示区域