为了账号安全,请及时绑定邮箱和手机立即绑定

我这个写法,为什么css样式没有生效呢?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>盒子模型练习题</title>
<style type="text/css">
<!--在此定义一个类选择器myBox,根据要求设置相关CSS属性-->
.myBox{
width:200px;
height:100px;
border:1px solid #F00;
margin-top:10px;
padding-left:15px;
}
</style>
</head>
<body>
<div class="myBox">Hello World</div>
</body>
</html>


正在回答

4 回答

<!-- -->是HTML注释,而你把它放在了CSS语言区内,浏览器无法辨别  正确的做法是:把这段注释放在<style></style>外部

1 回复 有任何疑惑可以回复我~

我也是一样的代码,第一行

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

左边显示有一个红叉,不知道是怎么回事

0 回复 有任何疑惑可以回复我~

你把这个放到myeclipse或者DW中试一试。有的时候网页编辑器会显示不了。

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

我这个写法,为什么css样式没有生效呢?

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信