css左浮动失效

.news{width:340px;border:1px;solid#E8E8E8;}.course{width:410px;border:1px;solid#E8E8E... .news{ width:340px; border:1px; solid #E8E8E8;}.course{ width:410px; border:1px; solid #E8E8E8; margin:0 7px;}.sidebar{ width:230px; float: left; display: inline; height: 250px;}.news,.course,{ float:left; height:250px; display: inline; border: 1px solid #E8E8E8;}.title{ height:35px; border-bottom:2px solid #E8E8E8;}.title_left{ width:70%; font-family:"微软雅黑"; font-size:14px; font-weight:bold; color:#786F66; float:left; line-height:35px; padding-left:20px;}.title_right{ width:20%; float:right; line-height:35px; text-align:right; padding-right:10px;}.title_right a{ text-decoration:none; color:#999999;}.pic_news{ height:80px; margin-top:10px; line-height:22px;}.pic_news img,.course_pic img{ float:left; margin:0 5px;}.pic_news a,.course_pic a{ color:#C00; text-decoration:none;}.news_list{ margin-top:10px;}.news_list li{ list-style-type:none; background:url(../images/list.jpg) no-repeat; padding-left:10px; margin:8px; border-bottom:1px dotted #CCC;}.news_list a:link,.news_list a:visited{ color:#000; text-decoration:none;}.news_list a:hover,.news_list a:active{ color:#F0F; text-decoration:none;}.data{ color:#999; float:right;}.course{ height:120px;; margin-top:10px; line-height:22px;}.course_type{ height:37px; width:372px; background:url(../images/product_type_bg.jpg) no-repeat; margin:20px auto;}.course_type li{ list-style-type:none; float:left; line-height:37px; margin:0 15px; text-align:center;} 展开
 我来答
若以下回答无法解决问题,邀请你更新回答
草原上之狼
高粉答主

2017-09-19 · 醉心答题,欢迎关注
知道大有可为答主
回答量:2.9万
采纳率:93%
帮助的人:4382万
展开全部
在div+css中浮动不起作用,可能是原因是你设置flaot的这个元素不是块级元素,所以float对它是不起任何作用的,如span和a这些标签,我这里写个代码:
<html>
<head>
<style>
#sub{ //通过id实现
width:300px; //只是假定的值,需要根据实际的要求写。
height:30px;
float:left;
}

span{ //通过id实现
width:300px;
height:30px;
float:left; 不是块级元素,不会有float属性的
}

</head>
<body>
<div>
<div id=sub>测试文字,</div>
<span>我不会浮动的</span>
</div>
</body>
</html>
我们想要浮动的话,只要将span那在加一个display:block;就能够实现浮动了。
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式