html怎么去掉空格
程序员文章站
2022-04-02 22:25:33
...
html去掉空格的方法:首先打开相应的HTML代码文件;然后通过在父元素上设置“font-size:0;”样式即可去除html代码标签之间换行产生的空格。
本文操作环境:windows7系统、HTML5&&CSS3版、Dell G3电脑。
如何去除html代码标签之间换行产生的空格
当使用inline-block时,HTML元素之间的空白会显示在页面上,为了保持代码的美观,不建议使用全部写在一行内或者影响美观的方法。
推荐方法:在父元素上设置
font-size: 0;
例:
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title> <style> body { margin: 0; padding: 0; } p { height: 41px; border-top: 4px solid red; border-bottom: 1px solid gray; } a { display: inline-block; height: 41px; text-align: center; line-height: 41px; text-decoration: none; padding: 0px 5px; background-color: red; font-size: 14px; font-family: 楷体; } .shouye { margin-left: 200px; } .shouye:hover { background-color: gray; } </style></head><body> <p> <a class="shouye" href="#">设为首页</a> <a href="#">手机新浪网</a> <a href="#">移动客户端</a> </p></body></html>
效果预览:
修改后代码:
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title> <style> body { margin: 0; padding: 0; } p { font-size: 0;/*关键代码*/ height: 41px; border-top: 4px solid red; border-bottom: 1px solid gray; } a { display: inline-block; height: 41px; text-align: center; line-height: 41px; text-decoration: none; padding: 0px 5px; background-color: red; font-size: 14px; font-family: 楷体; } .shouye { margin-left: 200px; } .shouye:hover { background-color: gray; } </style></head><body> <p> <a class="shouye" href="#">设为首页</a> <a href="#">手机新浪网</a> <a href="#">移动客户端</a> </p></body></html>
效果预览:
【推荐学习:HTML视频教程】
以上就是html怎么去掉空格的详细内容,更多请关注其它相关文章!
上一篇: html如何改变字体颜色
下一篇: textarea标签有什么用
推荐阅读
-
ps图片拖到另一个图层的小标记怎么去掉?
-
怎么把这段html代码转换成php代码
-
WPS表格转换的柱形图或者扇形图图表外的黑色边框怎么去掉
-
HTML的DELETE和PUT应该怎么使用?_html/css_WEB-ITnose
-
去掉织梦建站或者仿站时首页访问地址后的index.html
-
怎么让iframe嵌套frameset框架,点击导航栏中超链接,浏览器url改变??_html/css_WEB-ITnose
-
怎么实现背景色从中间往两边渐变?_html/css_WEB-ITnose
-
sfhover 怎么工任的?_html/css_WEB-ITnose
-
移除行块级元素之间的空格(译文)_html/css_WEB-ITnose
-
网页上的.swf如何下载?帮我看看这个怎么下载_html/css_WEB-ITnose