猿问

CSS 未正确应用

仍在学习中,我已尽我所知尽一切努力来完成这项工作。

我正在尝试应用以下内容:

https://codepen.io/tech-lane/pen/XWbqGyx

到我在此处找到的布局中的标题:

https://www.w3schools.com/howto/tryit.asp?filename=tryhow_make_a_website

应用它时,CSS 无法正确设置其样式。我希望这里有人能指出我正确的方向。


墨色风雨
浏览 115回答 1
1回答

胡子哥哥

试试这个代码:<!DOCTYPE html><html><head>&nbsp; <title>Page Title</title>&nbsp; <meta charset="UTF-8">&nbsp; <meta name="viewport" content="width=device-width, initial-scale=1">&nbsp; <style>&nbsp; &nbsp; * {&nbsp; &nbsp; &nbsp; box-sizing: border-box;&nbsp; &nbsp; }&nbsp; &nbsp; /* Style the body */&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; body {&nbsp; &nbsp; &nbsp; font-family: Arial, Helvetica, sans-serif;&nbsp; &nbsp; &nbsp; margin: 0;&nbsp; &nbsp; }&nbsp; &nbsp; /* Header/logo Title */&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .header {&nbsp; &nbsp; &nbsp; padding: 80px;&nbsp; &nbsp; &nbsp; text-align: center;&nbsp; &nbsp; &nbsp; background: #1abc9c;&nbsp; &nbsp; &nbsp; color: white;&nbsp; &nbsp; }&nbsp; &nbsp; /* Increase the font size of the heading */&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .header h1 {&nbsp; &nbsp; &nbsp; font-size: 40px;&nbsp; &nbsp; }&nbsp; &nbsp; /* Style the top navigation bar */&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .navbar {&nbsp; &nbsp; &nbsp; overflow: hidden;&nbsp; &nbsp; &nbsp; background-color: #333;&nbsp; &nbsp; }&nbsp; &nbsp; /* Style the navigation bar links */&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .navbar a {&nbsp; &nbsp; &nbsp; float: left;&nbsp; &nbsp; &nbsp; display: block;&nbsp; &nbsp; &nbsp; color: white;&nbsp; &nbsp; &nbsp; text-align: center;&nbsp; &nbsp; &nbsp; padding: 14px 20px;&nbsp; &nbsp; &nbsp; text-decoration: none;&nbsp; &nbsp; }&nbsp; &nbsp; /* Right-aligned link */&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .navbar a.right {&nbsp; &nbsp; &nbsp; float: right;&nbsp; &nbsp; }&nbsp; &nbsp; /* Change color on hover */&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .navbar a:hover {&nbsp; &nbsp; &nbsp; background-color: #ddd;&nbsp; &nbsp; &nbsp; color: black;&nbsp; &nbsp; }&nbsp; &nbsp; /* Column container */&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .row {&nbsp; &nbsp; &nbsp; display: -ms-flexbox;&nbsp; &nbsp; &nbsp; /* IE10 */&nbsp; &nbsp; &nbsp; display: flex;&nbsp; &nbsp; &nbsp; -ms-flex-wrap: wrap;&nbsp; &nbsp; &nbsp; /* IE10 */&nbsp; &nbsp; &nbsp; flex-wrap: wrap;&nbsp; &nbsp; }&nbsp; &nbsp; /* Create two unequal columns that sits next to each other */&nbsp; &nbsp; /* Sidebar/left column */&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .side {&nbsp; &nbsp; &nbsp; -ms-flex: 30%;&nbsp; &nbsp; &nbsp; /* IE10 */&nbsp; &nbsp; &nbsp; flex: 30%;&nbsp; &nbsp; &nbsp; background-color: #f1f1f1;&nbsp; &nbsp; &nbsp; padding: 20px;&nbsp; &nbsp; }&nbsp; &nbsp; /* Main column */&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .main {&nbsp; &nbsp; &nbsp; -ms-flex: 70%;&nbsp; &nbsp; &nbsp; /* IE10 */&nbsp; &nbsp; &nbsp; flex: 70%;&nbsp; &nbsp; &nbsp; background-color: white;&nbsp; &nbsp; &nbsp; padding: 20px;&nbsp; &nbsp; }&nbsp; &nbsp; /* Fake image, just for this example */&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .fakeimg {&nbsp; &nbsp; &nbsp; background-color: #aaa;&nbsp; &nbsp; &nbsp; width: 100%;&nbsp; &nbsp; &nbsp; padding: 20px;&nbsp; &nbsp; }&nbsp; &nbsp; /* Footer */&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .footer {&nbsp; &nbsp; &nbsp; padding: 20px;&nbsp; &nbsp; &nbsp; text-align: center;&nbsp; &nbsp; &nbsp; background: #ddd;&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; @import url("https://fonts.googleapis.com/css?family=Lato:300,400|Poppins:300,400,800&display=swap");&nbsp; &nbsp; .container {&nbsp; &nbsp; &nbsp; width: 100%;&nbsp; &nbsp; &nbsp; display: flex;&nbsp; &nbsp; &nbsp; justify-content: center;&nbsp; &nbsp; &nbsp; align-items: center;&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .container * {&nbsp; &nbsp; &nbsp; margin: 0;&nbsp; &nbsp; &nbsp; padding: 0;&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .container .box {&nbsp; &nbsp; &nbsp; width: 250px;&nbsp; &nbsp; &nbsp; position: relative;&nbsp; &nbsp; &nbsp; display: flex;&nbsp; &nbsp; &nbsp; justify-content: center;&nbsp; &nbsp; &nbsp; flex-direction: column;&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .container .box .title {&nbsp; &nbsp; &nbsp; width: 100%;&nbsp; &nbsp; &nbsp; position: relative;&nbsp; &nbsp; &nbsp; display: flex;&nbsp; &nbsp; &nbsp; align-items: center;&nbsp; &nbsp; &nbsp; height: 50px;&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .container .box .title .block {&nbsp; &nbsp; &nbsp; width: 0%;&nbsp; &nbsp; &nbsp; height: inherit;&nbsp; &nbsp; &nbsp; background: #ffb510;&nbsp; &nbsp; &nbsp; position: absolute;&nbsp; &nbsp; &nbsp; animation: mainBlock 2s cubic-bezier(0.74, 0.06, 0.4, 0.92) forwards;&nbsp; &nbsp; &nbsp; display: flex;&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .container .box .title h1 {&nbsp; &nbsp; &nbsp; font-family: 'Poppins';&nbsp; &nbsp; &nbsp; color: #fff;&nbsp; &nbsp; &nbsp; font-size: 32px;&nbsp; &nbsp; &nbsp; -webkit-animation: mainFadeIn 2s forwards;&nbsp; &nbsp; &nbsp; -o-animation: mainFadeIn 2s forwards;&nbsp; &nbsp; &nbsp; animation: mainFadeIn 2s forwards;&nbsp; &nbsp; &nbsp; animation-delay: 1.6s;&nbsp; &nbsp; &nbsp; opacity: 0;&nbsp; &nbsp; &nbsp; display: flex;&nbsp; &nbsp; &nbsp; align-items: baseline;&nbsp; &nbsp; &nbsp; position: relative;&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .container .box .title h1 span {&nbsp; &nbsp; &nbsp; width: 0px;&nbsp; &nbsp; &nbsp; height: 0px;&nbsp; &nbsp; &nbsp; -webkit-border-radius: 50%;&nbsp; &nbsp; &nbsp; -moz-border-radius: 50%;&nbsp; &nbsp; &nbsp; border-radius: 50%;&nbsp; &nbsp; &nbsp; background: #ffb510;&nbsp; &nbsp; &nbsp; -webkit-animation: load 0.6s cubic-bezier(0.74, 0.06, 0.4, 0.92) forwards;&nbsp; &nbsp; &nbsp; animation: popIn 0.8s cubic-bezier(0.74, 0.06, 0.4, 0.92) forwards;&nbsp; &nbsp; &nbsp; animation-delay: 2s;&nbsp; &nbsp; &nbsp; margin-left: 5px;&nbsp; &nbsp; &nbsp; margin-top: -10px;&nbsp; &nbsp; &nbsp; position: absolute;&nbsp; &nbsp; &nbsp; bottom: 13px;&nbsp; &nbsp; &nbsp; right: -12px;&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .container .box .wordCarousel {&nbsp; &nbsp; &nbsp; font-size: 36px;&nbsp; &nbsp; &nbsp; font-weight: 100;&nbsp; &nbsp; &nbsp; color: #939393;&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .container .box .wordCarousel div {&nbsp; &nbsp; &nbsp; overflow: hidden;&nbsp; &nbsp; &nbsp; position: relative;&nbsp; &nbsp; &nbsp; float: left;&nbsp; &nbsp; &nbsp; height: 45px;&nbsp; &nbsp; &nbsp; padding-top: 5px;&nbsp; &nbsp; &nbsp; margin-top: -10px;&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .container .box .wordCarousel div li {&nbsp; &nbsp; &nbsp; font-family: Serif;&nbsp; &nbsp; &nbsp; color: #ccc;&nbsp; &nbsp; &nbsp; font-weight: 250;&nbsp; &nbsp; &nbsp; padding: 0 5px;&nbsp; &nbsp; &nbsp; height: 45px;&nbsp; &nbsp; &nbsp; margin-bottom: 45px;&nbsp; &nbsp; &nbsp; display: block;&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; .flip4 {&nbsp; &nbsp; &nbsp; animation: flip4 15s cubic-bezier(1, 1, 0.32, 1.2) infinite;&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; @keyframes flip4 {&nbsp; &nbsp; &nbsp; 0% {&nbsp; &nbsp; &nbsp; &nbsp; margin-top: -360px;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; 5% {&nbsp; &nbsp; &nbsp; &nbsp; margin-top: -270px;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; 25% {&nbsp; &nbsp; &nbsp; &nbsp; margin-top: -270px;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; 30% {&nbsp; &nbsp; &nbsp; &nbsp; margin-top: -180px;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; 50% {&nbsp; &nbsp; &nbsp; &nbsp; margin-top: -180px;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; 55% {&nbsp; &nbsp; &nbsp; &nbsp; margin-top: -90px;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; 75% {&nbsp; &nbsp; &nbsp; &nbsp; margin-top: -90px;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; 80% {&nbsp; &nbsp; &nbsp; &nbsp; margin-top: 0px;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; 99.99% {&nbsp; &nbsp; &nbsp; &nbsp; margin-top: 0px;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; 100% {&nbsp; &nbsp; &nbsp; &nbsp; margin-top: -270px;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; @keyframes mainBlock {&nbsp; &nbsp; &nbsp; 0% {&nbsp; &nbsp; &nbsp; &nbsp; width: 0%;&nbsp; &nbsp; &nbsp; &nbsp; left: 0;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; 50% {&nbsp; &nbsp; &nbsp; &nbsp; width: 100%;&nbsp; &nbsp; &nbsp; &nbsp; left: 0;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; 100% {&nbsp; &nbsp; &nbsp; &nbsp; width: 0;&nbsp; &nbsp; &nbsp; &nbsp; left: 100%;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; @keyframes secBlock {&nbsp; &nbsp; &nbsp; 0% {&nbsp; &nbsp; &nbsp; &nbsp; width: 0%;&nbsp; &nbsp; &nbsp; &nbsp; left: 0;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; 50% {&nbsp; &nbsp; &nbsp; &nbsp; width: 100%;&nbsp; &nbsp; &nbsp; &nbsp; left: 0;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; 100% {&nbsp; &nbsp; &nbsp; &nbsp; width: 0;&nbsp; &nbsp; &nbsp; &nbsp; left: 100%;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; @keyframes mainFadeIn {&nbsp; &nbsp; &nbsp; 0% {&nbsp; &nbsp; &nbsp; &nbsp; opacity: 0;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; 100% {&nbsp; &nbsp; &nbsp; &nbsp; opacity: 1;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; @keyframes popIn {&nbsp; &nbsp; &nbsp; 0% {&nbsp; &nbsp; &nbsp; &nbsp; width: 0px;&nbsp; &nbsp; &nbsp; &nbsp; height: 0px;&nbsp; &nbsp; &nbsp; &nbsp; background: #e9d856;&nbsp; &nbsp; &nbsp; &nbsp; border: 0px solid #ddd;&nbsp; &nbsp; &nbsp; &nbsp; opacity: 0;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; 50% {&nbsp; &nbsp; &nbsp; &nbsp; width: 10px;&nbsp; &nbsp; &nbsp; &nbsp; height: 10px;&nbsp; &nbsp; &nbsp; &nbsp; background: #e9d856;&nbsp; &nbsp; &nbsp; &nbsp; opacity: 1;&nbsp; &nbsp; &nbsp; &nbsp; bottom: 45px;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; 65% {&nbsp; &nbsp; &nbsp; &nbsp; width: 7px;&nbsp; &nbsp; &nbsp; &nbsp; height: 7px;&nbsp; &nbsp; &nbsp; &nbsp; bottom: 0px;&nbsp; &nbsp; &nbsp; &nbsp; width: 15px;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; 80% {&nbsp; &nbsp; &nbsp; &nbsp; width: 10px;&nbsp; &nbsp; &nbsp; &nbsp; height: 10px;&nbsp; &nbsp; &nbsp; &nbsp; bottom: 20px;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; 100% {&nbsp; &nbsp; &nbsp; &nbsp; width: 7px;&nbsp; &nbsp; &nbsp; &nbsp; height: 7px;&nbsp; &nbsp; &nbsp; &nbsp; background: #e9d856;&nbsp; &nbsp; &nbsp; &nbsp; border: 0px solid #222;&nbsp; &nbsp; &nbsp; &nbsp; bottom: 13px;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; @keyframes secFadeIn {&nbsp; &nbsp; &nbsp; 0% {&nbsp; &nbsp; &nbsp; &nbsp; opacity: 0;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; 100% {&nbsp; &nbsp; &nbsp; &nbsp; opacity: 0.5;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }&nbsp; &nbsp; /* Responsive layout - when the screen is less than 700px wide, make the two columns stack on top of each other instead of next to each other */&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; @media screen and (max-width: 700px) {&nbsp; &nbsp; &nbsp; .row {&nbsp; &nbsp; &nbsp; &nbsp; flex-direction: column;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }&nbsp; &nbsp; /* Responsive layout - when the screen is less than 400px wide, make the navigation links stack on top of each other instead of next to each other */&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; @media screen and (max-width: 400px) {&nbsp; &nbsp; &nbsp; .navbar a {&nbsp; &nbsp; &nbsp; &nbsp; float: none;&nbsp; &nbsp; &nbsp; &nbsp; width: 100%;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }&nbsp; </style></head><body>&nbsp; <div class="header">&nbsp; &nbsp; <div class="container">&nbsp; &nbsp; &nbsp; <div class="box">&nbsp; &nbsp; &nbsp; &nbsp; <div class="title">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="block"></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <h1>Lane Willmore<span></span></h1>&nbsp; &nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; &nbsp; &nbsp; <!-- here role goes -->&nbsp; &nbsp; &nbsp; &nbsp; <h4 class="wordCarousel">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <!--&nbsp; &nbsp; &nbsp; &nbsp; Use classes 2,3, or 4 to match the number of words -->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ul class="flip4">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>word 1</li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>word 2</li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>word 3</li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>word 4</li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ul>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; &nbsp; &nbsp; </h4>&nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; </div>&nbsp; </div>&nbsp; <div class="navbar">&nbsp; &nbsp; <a href="#">Link</a>&nbsp; &nbsp; <a href="#">Link</a>&nbsp; &nbsp; <a href="#">Link</a>&nbsp; &nbsp; <a href="#" class="right">Link</a>&nbsp; </div>&nbsp; <div class="row">&nbsp; &nbsp; <div class="side">&nbsp; &nbsp; &nbsp; <h2>About Me</h2>&nbsp; &nbsp; &nbsp; <h5>Photo of me:</h5>&nbsp; &nbsp; &nbsp; <div class="fakeimg" style="height:200px;">Image</div>&nbsp; &nbsp; &nbsp; <p>Some text about me in culpa qui officia deserunt mollit anim..</p>&nbsp; &nbsp; &nbsp; <h3>More Text</h3>&nbsp; &nbsp; &nbsp; <p>Lorem ipsum dolor sit ame.</p>&nbsp; &nbsp; &nbsp; <div class="fakeimg" style="height:60px;">Image</div><br>&nbsp; &nbsp; &nbsp; <div class="fakeimg" style="height:60px;">Image</div><br>&nbsp; &nbsp; &nbsp; <div class="fakeimg" style="height:60px;">Image</div>&nbsp; &nbsp; </div>&nbsp; &nbsp; <div class="main">&nbsp; &nbsp; &nbsp; <h2>TITLE HEADING</h2>&nbsp; &nbsp; &nbsp; <h5>Title description, Dec 7, 2017</h5>&nbsp; &nbsp; &nbsp; <div class="fakeimg" style="height:200px;">Image</div>&nbsp; &nbsp; &nbsp; <p>Some text..</p>&nbsp; &nbsp; &nbsp; <p>Sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.</p>&nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; <h2>TITLE HEADING</h2>&nbsp; &nbsp; &nbsp; <h5>Title description, Sep 2, 2017</h5>&nbsp; &nbsp; &nbsp; <div class="fakeimg" style="height:200px;">Image</div>&nbsp; &nbsp; &nbsp; <p>Some text..</p>&nbsp; &nbsp; &nbsp; <p>Sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.</p>&nbsp; &nbsp; </div>&nbsp; </div>&nbsp; <div class="footer">&nbsp; &nbsp; <h2>Footer</h2>&nbsp; </div></body></html>
随时随地看视频慕课网APP

相关分类

Html5
我要回答