不能在CSS中使用p.class

时间:2016-07-26 19:25:39

标签: html css

未应用p.bull CSS样式。其他一切都是,但不是p.bull风格。

我的CSS

h1.heading
{
    text-align: center;

}
h1.sideheading
{
    color : blue;
    text-decoration: underline; 

p.bull
{
    color : blue;
} 

我的HTML

<head>
    <title>jfk flight</title>
    <link rel="stylesheet" type="text/css" href="cascard.css">
</head>

<body>
    <h1 class="heading"> john f kennedy </h1>
    <h1 class="heading"> jfk@gmail.com</h1>
    <h1 class="heading"> Ph: 111 111 1111 </h1>

    <h1 class="sideheading"> Objective </h1>
    <p> seeking flight timings. </p>

    <h1 class="sideheading"> Profile </h1>
    <p class="bull"> •  kajshfjhdfkjhk</br>•    kjadfkjhasldkjasf.</br>•    kjasfkhj.</br>• jasgfjhgashg </p

</body>

2 个答案:

答案 0 :(得分:3)

CSS语法中有错误。你没有关闭h1.sideheading

<强> CSS

h1.sideheading
{
    color : blue;
    text-decoration: underline;
}   /*  <--- Add Closing Bracket */

h1.heading
{
	text-align: center;
	
}
h1.sideheading
{
	color : blue;
	text-decoration: underline;
}

p.bull
{
	color : blue;
} 

> here this part is not executing.Except p.bull everything is good
//everything else is executing except that bull class
<html>
	<head>
		<title>jfk flight</title>
		<link rel="stylesheet" type="text/css" href="cascard.css">
	</head>

	<body>
		<h1 class="heading"> john f kennedy </h1>
		<h1 class="heading"> jfk@gmail.com</h1>
		<h1 class="heading"> Ph: 111 111 1111 </h1>

		<h1 class="sideheading"> Objective </h1>
		<p> seeking flight timings. </p>
		
		<h1 class="sideheading"> Profile </h1>
		<p class="bull"> •	kajshfjhdfkjhk</br>•	kjadfkjhasldkjasf.</br>•	kjasfkhj.</br>•	jasgfjhgashg </p

> here, I declared p as a class name bull and referring in CSS.

	
	</body>
</html>

答案 1 :(得分:1)

您的代码中有错误:h1.sideheading

没有结束花括号
h1.heading
{
    text-align: center;

}
h1.sideheading
{
    color : blue;
    text-decoration: underline; 
}    /* <<< ADD THIS HERE */
p.bull
{
    color : blue;
} 

另外,您没有关闭<p>代码。您有</p,应该是</p>