CSS,用文本填充所有div宽度 [英] CSS, fill all div width with text

查看:1063
本文介绍了CSS,用文本填充所有div宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何自动更改字母之间的空格。我希望文本占据div的整个宽度。文本不是静态的。 (始终更改文本,可以是123或文本文本...)

 < style type =text / css> 
#menu {
width:200px;
background-color:#000;
color:#336699;
font-size:16px;
letter-spacing:100%;
}
< / style>
< body>
< div id =menu>
tekstas
< / div>


解决方案

strong> EDIT:不幸的是,这只改变了间距,而不是字母间距。 p>

这可以通过 text-align:justify CSS属性轻松完成:

  #menu 
{
width:200px;
background-color:#000;
color:#336699;
font-size:16px;
text-align:justify;
}


How to automatically change the space between the letters.I want the text to take up the entire width of the div. Text is not static. (Always changing text, can be 123" or "text text"...)

  <style type="text/css">
    #menu{
      width: 200px;
      background-color: #000;
      color: #336699;
      font-size: 16px;
      letter-spacing: 100%;
    }
  </style>
<body>
<div id="menu">
  tekstas
</div>

解决方案

EDIT: Unfortunately this only changes word spacing, not letter spacing. There is not way to do kerning in CSS. Possibly CSS3, however.

This is easily accomplished with the text-align: justify CSS attribute:

#menu 
{ 
      width: 200px; 
      background-color: #000; 
      color: #336699; 
      font-size: 16px; 
      text-align: justify; 
}

这篇关于CSS,用文本填充所有div宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆