简体   繁体   English

如何在 css 中设置跨度分词

[英]How to set word break in span in css

I am using the radio buttons but the label beside the radio button is too long for the fixed screen.我正在使用单选按钮,但单选按钮旁边的 label 对于固定屏幕来说太长了。 So some part of text is not showing.所以文本的某些部分没有显示。 I tried word-break:break-word but it doesnt work.我尝试word-break:break-word但它不起作用。 Currently the code is目前代码是

<label class="ant-radio-wrapper"><span class="ant-radio"><input type="radio" class="ant-radio-input" value="1"><span class="ant-radio-inner"></span></span><span>Comté Réserve PDO 36-42 Months Old 200g</span></label>

and it looks like它看起来像在此处输入图像描述

How to fix this?如何解决这个问题? Thanks in advance提前致谢

This one is easy.这很容易。 You can put a tag break <br> inside tag span to break the line.您可以在标签跨度内放置一个标签 break <br>来换行。

You have two options in my opinion but there are a lot.在我看来,你有两个选择,但有很多。

First One:第一:

you can use flexbox if you know it's good otherwise you just need to put these below CSS in your ant-radio-wrapper class name.如果你知道它很好,你可以使用 flexbox 否则你只需要将这些放在 CSS 的下方,在你的 ant-radio-wrapper class 名称中。

.ant-radio-wrapper {
 display: flex;
 flex-wrap: wrap;
}

Second One:第二个:

You can resize your font size by default font size is 16px您可以调整字体大小,默认字体大小为 16px

.ant-radio-wrapper {
  font-size: 12px
}

The long answer is, there's something wrong with your layout.长答案是,您的布局有问题。 Normally a line of text in a span will break to a new line.通常,跨度中的一行文本将换行。

 .container{ width:200px; border:solid 2px #333; }
 <div class="container"> <label class="ant-radio-wrapper"> <span class="ant-radio"> <input type="radio" class="ant-radio-input" value="1"/> <span class="ant-radio-inner"></span> </span> <span>Comté Réserve PDO 36-42 Months Old 200g</span> </label> </div>

Use flexbox使用 flexbox

 label { display: flex; /* for demo */ width: 200px; }
 <label class="ant-radio-wrapper"><span class="ant-radio"><input type="radio" class="ant-radio-input" value="1"><span class="ant-radio-inner"></span></span><span>Comté Réserve PDO 36-42 Months Old 200g</span></label>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM