Html 带边框的 CSS 跨度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22230474/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 01:09:05  来源:igfitidea点击:

CSS span with border

htmlcss

提问by theLaw

Hi i don't get why my span with border looks like this

嗨,我不明白为什么我的带边框的跨度看起来像这样

enter image description here

在此处输入图片说明

this is the css behind

这是后面的css

color:red; 
font-size: 12px;
background-color: #ffcaca;
background-image:url(/Content/x.png);
background-size: 20px 20px;
background-repeat:no-repeat;
background-position:2px;
padding: 5px;
border-radius: 5px 5px 5px;
border: 1px solid red;
padding-left: 25px;
position:relative;

and html

和 html

<tr>
    <td>
        <span>[...]</span>
    <td>
<tr>

回答by Mr_Green

You can give display: blockto the span element or use divelement instead of using spanelement.

您可以给display: blockspan 元素或使用div元素而不是使用span元素。

I would prefer the latter one.

我更喜欢后者。

回答by JeanCharles Amey

if you are stuck in a wordpress theme because you don't want to touch to the template and you just want to add custom css, using display: blockor display: inline-blockwill be perfect.

如果您因为不想接触模板而被困在 wordpress 主题中,而只想添加自定义 css,那么使用display: blockdisplay: inline-block将是完美的。