如何去掉HTML中换行造成的空格
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何去掉HTML中换行造成的空格相关的知识,希望对你有一定的参考价值。
参考技术A思路:在父元素上设置font-size: 0;
font-size定义和用法
font-size 属性可设置字体的尺寸。
去掉html中换行造成的空格代码参考如下:
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8">
<title>Document</title>
<style>
body
margin: 0;
padding: 0;
div
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>
<div>
<a class="shouye" href="#">设为首页</a>
<a href="#">手机新浪网</a>
<a href="#">移动客户端</a>
</div></body></html>
微信小程序中换行,空格(多个空格)写法
在小程序中HTML的网页实体无法正常使用,小程序中的写法为:
一、空格,换行
<text>你好!\t七月流火啊!\n我在下一行</text>
\t 空格( 多个只会显示一个空格)
\n 换行
二、连续空格
<view> <text space="ensp">你好 啊 哈哈哈(空格是中文字符一半大小)</text> </view> <view> <text space="emsp">你好 啊 哈哈哈(空格是中文字符大小)</text> </view> <view> <text space="nbsp">你好 啊 哈哈哈(空格根据字体设置)</text> </view>
<view> <text decode="{{true}}">你好 啊   哈哈哈(空格是中文字符一半大小)</text> </view> <view> <text decode="{{true}}">你好 啊   哈哈哈(空格是中文字符大小)</text> </view> <view> <text decode="{{true}}">你好 啊 哈哈哈(空格根据字体设置)</text> </view>
友情提示:必须在<text>标签中!
以上是关于如何去掉HTML中换行造成的空格的主要内容,如果未能解决你的问题,请参考以下文章
iOS NSDictionary 转Json 去掉换行去掉空格