我在Codepen上构建了这个致敬页面。我加入了Bootsrap。然后我无法从css访问身体。你可以在这里查看我的代码。
body {
background-color: black;
}
.header {
font-size: 100px;
font-family: "Libre Barcode 39 Text";
text-align: center;
}
.mainPicture {
width: 95px;
}
<link href="https://fonts.googleapis.com/css?family=Libre+Barcode+39+Text" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<div class="container-fluid">
<h1 class="header">Travis<span><img class="mainPicture" src="https://ih0.redbubble.net/image.398989678.9673/ap,550x550,12x12,1,transparent,t.u1.png"></span>Scott</h1>
答案 0 :(得分:1)
Bootstrap风格覆盖了你的风格。使用!important来覆盖bootstrap样式。有关详细信息,请查看这些用法
html>body {
background-color: black;
}
.header {
font-size: 100px;
font-family: "Libre Barcode 39 Text";
text-align: center;
}
.mainPicture {
width: 95px;
}
&#13;
<link href="https://fonts.googleapis.com/css?family=Libre+Barcode+39+Text" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<div class="container-fluid">
<h1 class="header">Travis<span><img class="mainPicture" src="https://ih0.redbubble.net/image.398989678.9673/ap,550x550,12x12,1,transparent,t.u1.png"></span>Scott</h1>
&#13;
替代解决方案: -
使用html > body
来增加特异性,这将是一个很好的做法
html > body {
background-color: black;
}
.header {
font-size: 100px;
font-family: "Libre Barcode 39 Text";
text-align: center;
}
.mainPicture {
width: 95px;
}
&#13;
<link href="https://fonts.googleapis.com/css?family=Libre+Barcode+39+Text" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<div class="container-fluid">
<h1 class="header">Travis<span><img class="mainPicture" src="https://ih0.redbubble.net/image.398989678.9673/ap,550x550,12x12,1,transparent,t.u1.png"></span>Scott</h1>
&#13;