简体   繁体   English

如何防止文本与CSS中的其他文本不对齐

[英]How to keep text from mis-aligning with another in CSS

I'm using a plugin for my WordPress website and am having trouble with CSS. 我正在为我的WordPress网站使用插件,但CSS遇到了麻烦。 When the text description of the food item in the menu overflows and drops to the next line, it misaligns the price of the food. 当菜单中食物项目的文字说明溢出并跳至下一行时,它使食物的价格失准。 I've tried using word-wrap: break-word, padding and margins, but am unsure how to fix the problem. 我尝试使用自动换行:断行,填充和边距,但是不确定如何解决该问题。 If I make the text smaller it will of course be aligned properly but the problem will still occur if the text is too much and of course it's hard to read as well. 如果我缩小文本,当然可以正确对齐,但是如果文本太多,问题仍然会发生,当然也很难阅读。

problem: http://i.imgur.com/jYy4Vzg.jpg as you can see when the description overflows the price messes up. 问题: http : //i.imgur.com/jYy4Vzg.jpg正如您所看到的,说明溢出时价格混乱。

website: http://www.handynasty.net/ucity/menu/ -> drinks -> cocktails 网站: http : //www.handynasty.net/ucity/menu/- >饮料->鸡尾酒

Any help would be very much appreciated, thanks a lot! 任何帮助将不胜感激,非常感谢!

Just give the max-width to the parent of the item-text and desc 只需将最大宽度提供给item-text和desc的父项

Example: 例:

HTML HTML

<div class="desc-cont">
<p class="item-text">..</p>
<p class="desc">..</p>
</div>

CSS CSS

.desc-cont {
 max-width: 500px;
}

or 要么

.desc-cont{
max-width: calc(100% - 34px) // width of the value
}

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

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