在我的CSS媒体查询中,没有识别出一个特定的选择器

时间:2016-12-11 05:26:02

标签: css css-selectors media-queries

所以,我知道媒体查询正在运行,因为我设计的其他选择器工作正常。但是," div.A> #迎接"选择器根本不起作用。我在那里放了一个红色,所以我可以确定它什么时候工作,但文字保持相同的颜色,并且它没有移动。我真正需要处理的是文本中心。我已经尝试了所有我能想到或发现的东西。请帮助:)



/* .....show borders for sizing.... 

* {
	border: 1px solid black;
}

*/

body {
	box-sizing: border-box;
	align-content: center;
}

.A {
	margin-top: 4%;
}

#logo {
	height: 100px;
	width: 220px;
	float: left;
}

#greet {
	float: right;
	padding-top: 1%;
	padding-left: 10%;
}

div#greet > h1 {
  line-height: .01em;
  font-family: 'Titillium Web', sans-serif;
  text-transform: uppercase;
  color: #3D3D3D;
}

div#greet > h2 {
	font-family: 'Muli', sans-serif;
	color: #3D3D3D;
}

.jumbotron {
    position: relative;
    width: 100%;
    max-height: 500;
    overflow: hidden;
    background-color: #FFFFFF !important;
    margin: 0 !important;
}

.hero {
	position: relative;
	width: 100%;
	height: 100%;
	overflow: hidden;
	margin: 0;
}

#zippity {
	text-align: center;
	text-transform: uppercase;
	font-family: 'Titillium Web', sans-serif;
	padding-bottom: 1.5%;
	color: #3D3D3D;
	margin: 0;
}

.dooda {
	display: inline;
	text-align: center;
}

#Pics {
	height: 60%;
	max-width: 100%;
	padding-top: 8%;
	padding-bottom: 8%;
}

#BB {
	border-top: 3px solid #0D4B6E;
	border-bottom: 6px solid #0D4B6E;
	padding-top: 2%;
	padding-bottom: 1%;
}

div#BB > h1 {
	text-transform: uppercase;
	font-family: 'Muli', sans-serif;
	font-size: 200%;
	line-height: .001em;
	color: #3D3D3D;
	letter-spacing: -.04em;
}

div#BB > h2 {
	text-transform: lowercase;
	font-family: 'Bilbo', cursive;
	font-size: 230%;
	line-height: .5em;
	color: #BB1F25;
	letter-spacing: .03em;
}

footer#copy {
	background-color: #3D3D3D !important;
}

p {
	color: white;
	text-align: center;
	font-family: 'Muli', sans-serif;
}

.sam {
	text-decoration: underline;
}

/* for mobile */

@media screen and (max-width: 570px) {

	div.A > #logo {
		display: block;
		text-align: center;
		margin-left: auto;
		margin-right: auto;
		float: none;
		height: 30%;
		width: 50%;
	}

	div.A > #greet {
		float: none;
		text-align: center;
		color: #BB1F25;
	}
}

<!DOCTYPE html>
<html>
<head>
	
	<meta charset="utf-8"/>
	<title>Hello, I’m Sam</title>
	<link rel="stylesheet" type="text/css" href="css.css"/>
	<link href="https://fonts.googleapis.com  /css?family=Titillium+Web:600" rel="stylesheet">
	<link href="https://fonts.googleapis.com/css?family=Muli:300" rel="stylesheet">
  	<link href="https://fonts.googleapis.com/css?family=Bilbo" rel="stylesheet">  
	<meta name="viewport" content="width=device-width, initial-scale=1"> 
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  		<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</head>
<body>

	<div class="container">
		<div class="A">
			<img id="logo" src="Images/Logo.png"/>
			</div>
			<div id="greet">
				<h1>Hello, I'm Sam</h1>
				<h2>Web Designer</h2>
			</div>
		</div>
	</div>

	<img class="jumbotron hero" src="Images/hero1.jpg"/>

	<h1 id="zippity">Portfolio</h1>

	<div class="container">
		
		<div class="dooda row">

			<div class="tech col-md-4">
				<div id="BB">
					<h1>Technoline</h1>
					<h2>technoline.com</h2>
				</div>
				<img id="Pics" src="Images/technoline.jpg"/>
			</div>

			<div class="maj col-md-4">
				<div id="BB">
					<h1>Majestique</h1>
					<h2>majestique.com</h2>
				</div>
				<img id="Pics" src="Images/majestique.jpg"/>
			</div>

			<div class="sil col-md-4">
				<div id="BB">
					<h1>Silverzim</h1>
					<h2>silverzim.com</h2>
				</div>
				<img id="Pics" src="Images/silverzim.jpg"/>
			</div>

		</div>
	
	</div>

	<footer class="jumbotron" Id="copy">
		<p>&copy 2016 <span class="sam">Sam's Web Dev</span> All rights reserved</p>
	</footer>

</body>
</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

在您的HTML中,</div>元素之前的#greet结束标记(正如我在评论中提到的那样)使选择器失败,而且使用div.A > #greet > h1, div.A > #greet > h2

&#13;
&#13;
/* .....show borders for sizing.... 

* {
	border: 1px solid black;
}

*/

body {
	box-sizing: border-box;
	align-content: center;
}

.A {
	margin-top: 4%;
}

#logo {
	height: 100px;
	width: 220px;
	float: left;
}

#greet {
	float: right;
	padding-top: 1%;
	padding-left: 10%;
}

div#greet > h1 {
  line-height: .01em;
  font-family: 'Titillium Web', sans-serif;
  text-transform: uppercase;
  color: #3D3D3D;
}

div#greet > h2 {
	font-family: 'Muli', sans-serif;
	color: #3D3D3D;
}

.jumbotron {
    position: relative;
    width: 100%;
    max-height: 500;
    overflow: hidden;
    background-color: #FFFFFF !important;
    margin: 0 !important;
}

.hero {
	position: relative;
	width: 100%;
	height: 100%;
	overflow: hidden;
	margin: 0;
}

#zippity {
	text-align: center;
	text-transform: uppercase;
	font-family: 'Titillium Web', sans-serif;
	padding-bottom: 1.5%;
	color: #3D3D3D;
	margin: 0;
}

.dooda {
	display: inline;
	text-align: center;
}

#Pics {
	height: 60%;
	max-width: 100%;
	padding-top: 8%;
	padding-bottom: 8%;
}

#BB {
	border-top: 3px solid #0D4B6E;
	border-bottom: 6px solid #0D4B6E;
	padding-top: 2%;
	padding-bottom: 1%;
}

div#BB > h1 {
	text-transform: uppercase;
	font-family: 'Muli', sans-serif;
	font-size: 200%;
	line-height: .001em;
	color: #3D3D3D;
	letter-spacing: -.04em;
}

div#BB > h2 {
	text-transform: lowercase;
	font-family: 'Bilbo', cursive;
	font-size: 230%;
	line-height: .5em;
	color: #BB1F25;
	letter-spacing: .03em;
}

footer#copy {
	background-color: #3D3D3D !important;
}

p {
	color:white;
	text-align: center;
	font-family: 'Muli', sans-serif;
}

.sam {
	text-decoration: underline;
}

/* for mobile */

@media screen and (max-width: 570px) {

	div.A > #logo {
		display: block;
		text-align: center;
		margin-left: auto;
		margin-right: auto;
		float: none;
		height: 30%;
		width: 50%;
	}

	div.A > #greet > h1, div.A > #greet > h2 {
		float: none;
		text-align: center;
		color: #BB1F25;
	}
}
&#13;
<!DOCTYPE html>
<html>
<head>
	
	<meta charset="utf-8"/>
	<title>Hello, I’m Sam</title>
	<link rel="stylesheet" type="text/css" href="css.css"/>
	<link href="https://fonts.googleapis.com  /css?family=Titillium+Web:600" rel="stylesheet">
	<link href="https://fonts.googleapis.com/css?family=Muli:300" rel="stylesheet">
  	<link href="https://fonts.googleapis.com/css?family=Bilbo" rel="stylesheet">  
	<meta name="viewport" content="width=device-width, initial-scale=1"> 
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  		<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</head>
<body>

	<div class="container">
		<div class="A">
			<img id="logo" src="Images/Logo.png"/>
			<div id="greet">
				<h1>Hello, I'm Sam</h1>
				<h2>Web Designer</h2>
			</div>
		</div>
	</div>

	<img class="jumbotron hero" src="Images/hero1.jpg"/>

	<h1 id="zippity">Portfolio</h1>

	<div class="container">
		
		<div class="dooda row">

			<div class="tech col-md-4">
				<div id="BB">
					<h1>Technoline</h1>
					<h2>technoline.com</h2>
				</div>
				<img id="Pics" src="Images/technoline.jpg"/>
			</div>

			<div class="maj col-md-4">
				<div id="BB">
					<h1>Majestique</h1>
					<h2>majestique.com</h2>
				</div>
				<img id="Pics" src="Images/majestique.jpg"/>
			</div>

			<div class="sil col-md-4">
				<div id="BB">
					<h1>Silverzim</h1>
					<h2>silverzim.com</h2>
				</div>
				<img id="Pics" src="Images/silverzim.jpg"/>
			</div>

		</div>
	
	</div>

	<footer class="jumbotron" Id="copy">
		<p>&copy 2016 <span class="sam">Sam's Web Dev</span> All rights reserved</p>
	</footer>

</body>
</html>
&#13;
&#13;
&#13;

希望,这解决了你的问题!