怎么给html标签写css样式
2 回答
狐的传说
TA贡献1804条经验 获得超3个赞
1、直接使用行内样式,即在html标签上使用style
| 1 | <div style="width:100px;height:100px;background:red;">div内容</div> |
2、先定义css样式,再给html的class属性赋值
| 1234567891011 | <style>.content{ width:100px; height:100px; background:red;}</style> <div class="content"> div测试内容</div> |
总结:两种方式效果是一致的,只是第二种方式可进行重用,只要html元素class属性相同即可
冉冉说
TA贡献1877条经验 获得超1个赞
| 123456 | <style>.a{hegith:30px;}</style><div class="a"></div>等同于<div class="a" style="height:30px;"></div> |
- 2 回答
- 0 关注
- 946 浏览
添加回答
举报
0/150
提交
取消
