我正在为我的高中机器人团队开发一个网站。我有2个jumbotron元素但我需要修改其中一个jumbotron元素而不改变另一个。我该怎么做?
该网站是www.robotichive3774.com
<!DOCTYPE html>
<html>
<head>
<title>Robotics Team 3774 Home</title>
<!-- Link to stylesheet -->
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/index1.css">
<!-- Mobile Scaling -->
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<!-------------------- UNIFORM CODE ------------------------->
<!-- Navbar -->
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/Home">Team 3774</a>
</div>
<div class="navbar-collapse collapse" style="height: 0.866667px;">
<ul class="nav navbar-nav">
<li><a href="/Team Bio">Team Bio</a></li>
<li><a href="/Our Robot">Our Robot</a></li>
<li><a href="/Our Coach">Our Coach</a></li>
<li><a href="/Gallery">Gallery</a></li>
<li><a href="/Outreach">Outreach</a></li>
<li><a href="/Youtube">Youtube</a></li>
</ul>
</div>
</div>
</div>
<!-- Banner -->
<div class="jumbotron">
<img src="/Images/Banner.png" class="img-responsive" alt="Responsive image">
</div>
<!----------------------------------------------------------->
<div class="jumbotron">
<h1>Team 3774 Member Bio</h1>
<p>Here you can find links to every member with some information on each of them.</p>
</div>
<div class="container">
<div class="row">
<div class="col-md-4">
<h2>Abanoub Boules</h2>
<p>Team Captain, Engineer, Coder</p>
<button type="button" class="btn btn-default">Read More</button>
</div>
<div class="col-md-4">
<h2>Andre Bernardo</h2>
<p>Head Engineer, Assistant Captain</p>
<button type="button" class="btn btn-default">Read More</button>
</div>
<div class="col-md-4">
<h2>Leo Scarano</h2>
<p>Head Coder, Head Web-master</p>
<button type="button" class="btn btn-default">Read More</button>
</div>
<div class="col-md-4">
<h2>Andrew Wojtkowski</h2>
<p>Coder, Web-master, Engineer</p>
<button type="button" class="btn btn-default">Read More</button>
</div>
<div class="col-md-4">
<h2>Mina Hanna</h2>
<p>Engineer, Coder</p>
<button type="button" class="btn btn-default">Read More</button>
</div>
<div class="col-md-4">
<h2>Kenneth Rebbecke</h2>
<p>Engineer, Documenter</p>
<button type="button" class="btn btn-default">Read More</button>
</div>
<div class="col-md-4">
<h2>Kristen Kaldas</h2>
<p>Coder, Head Documenter</p>
<button type="button" class="btn btn-default">Read More</button>
</div>
<div class="col-md-4">
<h2>Melanie Aguilar</h2>
<p>Secretary, Mascot</p>
<button type="button" class="btn btn-default">Read More</button>
</div>
<div class="col-md-4">
<h2>Anish Patel</h2>
<p>Engineer, Head 3D Modelling</p>
<button type="button" class="btn btn-default">Read More</button>
</div>
<div class="col-md-4">
<h2>Furhan Ashraf</h2>
<p>Financial Advisor, Engineer</p>
<button type="button" class="btn btn-default">Read More</button>
</div>
</div>
</div>
</body>
</html>
我需要在网站顶部放置jumbotron元素以包含这些元素,但我不能将这些元素应用于第二个jumbotron。
.padding
{
padding-left:0;
padding-right:0;
padding-bottom:0;
}
答案 0 :(得分:2)
将id selector添加到您希望挑出的那个,例如id="top-jumbotron"
<!-- Banner -->
<div id="top-jumbotron" class="jumbotron">
<img src="/Images/Banner.png" class="img-responsive" alt="Responsive image">
</div>
然后使用ID选择器应用CSS:
#top-jumbotron {
padding-left:0;
padding-right:0;
padding-bottom:0;
}
请注意,页面上的ID必须是唯一的,这意味着您只能拥有一个#top-jumbotron
,一个#bottom-jumbotron
等。它们可用于挑选出需要特定样式或其他内容的独特元素适用于他们的方法。
ID选择器由主题标签#
表示,并且必须对页面唯一
示例:#top-jumbotron
类选择器由句点.
表示,可应用于页面上的一个或多个元素
示例:.jumbotron
或者,您可以使用.jumbotron
伪选择器单击页面上的第一个:first-child
类,如下所示:
.jumbotron:first-child
{
padding-left:0;
padding-right:0;
padding-bottom:0;
}
但是对于您的情况,我建议使用特定的目标ID,以便您知道它始终应用于正确的超大屏幕。