日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

中國最全IT社區(qū)平臺 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2

css教程

CSS 教程

CSS 響應式設計

CSS實例

拓展閱讀

CSS兩端對齊語法及代碼實例教學

閱讀 (2147)

我們都對“兩端對齊”并不陌生,在word、powerpoint、outlook等界面工具欄里,都有兩端對齊(分散對齊)的功能按鈕,只是平時使用的并不是太多,從編輯習慣上來說基本都是用左對齊、居中對齊、右對齊的方式來對齊頁面的文本或模塊,而當我們在做表單的時候經(jīng)常遇到比如姓名, 手機號碼, 出生地等等字段長短不一的情況,此時就需要用css讓兩個字段的詞語兩端對齊才能使整體表單看起來比較協(xié)調(diào),如下圖所示:


注冊表單


css文字兩端對齊

text-align:Justify(火狐);
text-justify:inter-ideograph(IE)

text-justify(IE)
基本語法

text-justify : auto | distribute | distribute-all-lines | distribute-center-last | inter-cluster | inter-ideograph | inter-word | kashida | newspaper


語法取值

auto : 默認值。允許瀏覽器代理用戶確定使用的兩端對齊法則

distribute : 處理空格很像 newspaper ,適用于東亞文檔。尤其是泰文

distribute-all-lines : 兩端對齊行的方式與

distribute 相同,也同樣不包含兩段對齊段落的最后一行。適用于表意字文檔

distribute-center-last : 未實現(xiàn)

inter-cluster : 調(diào)整文本無詞間空格的行。這種模式的調(diào)整是用于優(yōu)化亞洲語言文檔的

inter-ideograph : 為表意字文本提供完全兩端對齊。他增加或減少表意字和詞間的空格

inter-word : 通過增加字之間的空格對齊文本。該行為是對齊所有文本行最快的方法。它的兩端對齊行為對段落的最后一行無效

kashida : 通過拉長選定點的字符調(diào)整文本。這種調(diào)整模式是特別為阿拉伯腳本語言提供的。需要IE5.5+支持

newspaper : 通過增加或減少字或字母之間的空格對齊文本。是用于拉丁文字母表兩端對齊的最精確格式

應用代碼實例

如上圖所示的注冊表單,我們就要用到 text-align, text-justify樣式了。 text-align直接設為justify就行了,text-justify的情況相對比較復雜 。

代碼如下:
<form> 
<div> 
<span>用 戶 名</span> 
<input id='username' type="text" name="" /> 
<strong></strong> 
</div> 
<div> 
<span>密 碼</span> 
<input type="password" name="" /> 
<strong></strong> 
</div> 
<div> 
<span>確 認 密 碼</span> 
<input type="password" name="" /> 
<strong></strong> 
</div> 
<div> 
<span>興 趣 愛 好</span> 
<input type="text" name="" /> 
<strong></strong> 
</div> 
<div class='reg'> 
<input type="button" value='點此注冊' name="" /> 
</div> 
</form 

注意,在沒兩個字符之間是有一個空格的 

樣式代碼:
/*CSS reset 頂部為css的重置代碼*/ html{color:#000;background:#FFF;font-family:Microsoft YaHei,sans-serif,Arial,'宋體';} body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td,strong{padding:0;margin:0;font-family:Microsoft YaHei,sans-serif,Arial;} table{border-collapse:collapse;border-spacing:0;} fieldset,img{border:0;} a{text-decoration:none; color:#; outline:none;}/*此處待添加默認鏈接顏色*/ a:hover{text-decoration:none;color:#cb1114}; var,em,strong{font-style:normal;} address,caption,cite,code,dfn,em,strong,th,var, optgroup{font-style:inherit;font-weight:inherit;} del,ins{text-decoration:none;} li{list-style:none;} caption,th{text-align:left;} h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;} q:before,q:after{content:'';} abbr,acronym{border:0;font-variant:normal;} sup{vertical-align:baseline;} sub{vertical-align:baseline;} legend{color:#000;} input,button,textarea,select,optgroup,option{font-family:inherit; font-size:inherit;font-style:inherit;font-weight:inherit;} input,button,textarea,select{*font-size:100%;} .clear {clear:both;height:0px;overflow:hidden;} body{-webkit-user-select:none;-webkit-text-size-adjust:none;-webkit-transform-style:preserve-3d;} *{-webkit-tap-highlight-color:rgba(0,0,0,0);} /*form 從此處起為表單的樣式處理*/ form{width:430px;margin:20px auto 0;} div{ 
width:430px; 
height:40px; 
line-height:40px; 
clear:both; 
word-spacing:-1em;/*調(diào)整文本,以防止使用兩端對齊之后字間距過大*/ 
text-align:justify; 
text-justify:distribute-all-lines;/*ie6-8*/ 
text-align-last:justify;/* ie9*/ 
-moz-text-align-last:justify;/*ff*/ 
-webkit-text-align-last:justify;/*chrome 20+*/ 
} @media screen and (-webkit-min-device-pixel-ratio:0){/* 兼容chrome*/ div span:after{ content:"."; display: inline-block; width:100%; overflow:hidden; height:0; } } span{float:left;width:65px;height:40px;line-height:40px;margin-right:10px;} strong{float:left;width:140px;height:40px;line-height:40px;margin-left:10px;background:#ccf;} input[type=text]{float:left;width:200px;height:20px;margin:10px 0;} input[type=password]{float:left;width:200px;height:20px;margin:10px 0;} input[type=button]{color:#00f;width:100px;height:30px;} .reg{text-align:center;margin:20px auto 0;} 

使用text-align:justify;和text-justify:inter-ideograph;設置文字兩端對齊的效果,無論是英文還是中文,在IE和chrome下都不起作用。解決方法如下:

樣式代碼:
div.justify 
{ 
  text-align: justify; width:200px; font-size:15px; color:red; 
  border:1px solid blue; height:18px;
}
div.justify > span 
{ 
  display: inline-block /* Opera */; 
  padding-left: 100%; 
}
HTML:

<div class="justify">hello, text justify.</div><br/>
<div class="justify"> hello, text justify.<span></span></div><br/>
<div class="justify">中 文 兩 端 對 齊</div><br/>
<div class="justify">中 文 兩 端 對 齊<span></span></div>
效果圖:
兩端對齊

從效果圖可以看到,除了要在塊級元素加text-align:justify樣式外,還需要在里面加一個空的span元素,并應用樣式。另外,對于中文還必須用空格隔開漢字,否則也沒有兩端對齊的效果。英文每個單詞都有空格隔開,所以沒問題。

兩端對齊英文文字的css代碼

代碼如下:
<div style="text-align:justify;">
中間是英文資料
</div>


<div align="justify">
中間是英文資料
</div>
這樣就英文顯示就可以對齊了,單詞也不會斷開。
但是有時候我們需要單詞斷開就在后面加個“-”,怎樣做呢?代碼如下:
<div style="text-align:justify;text-justify:inter-ideograph;">
中間是英文資料
</div>
這樣就可以了,不過這個代碼好像只有在IE里用。
--------------------------------------------------------------------

如果上面代碼沒效果,可以參考下面的代碼:

div.justify { text-align: justify; width:200px; font-size:15px; color:red; border:1px solid blue; height:18px;}
div.justify > span { display: inline-block /* Opera */; padding-left: 100%; }
<div class="justify">hello, text justify.</div><br/>
<div class="justify"> hello, text justify.<span></span></div><br/>
<div class="justify">中 文 兩 端 對 齊</div><br/>
<div class="justify">中 文 兩 端 對 齊<span></span></div>
除了要在塊級元素加text-align:justify樣式外,還需要在里面加一個空的span元素,并應用樣式。另外,對于中文還必須用空格隔開漢字,否則也沒有兩端對齊的效果。英文每個單詞都有空格隔開,所以沒問題。
關(guān)閉
程序員人生
主站蜘蛛池模板: 黄色一级片在线免费观看 | 国产亚洲精品久 | 99精品国产一区二区三区 | 人人精品| 久久久久久女乱国产 | 亚洲国产精品久久久 | 婷婷成人在线 | 亚洲一区二区三区中文字幕 | 男女av| 91伦理视频在线观看 | 欧美日韩精品一区二区三区 | 国产精品欧美激情 | 日韩免费一区二区 | 亚洲精品高清视频 | 最近中文免费字幕 | 国产欧美一区二区三区另类精品 | 亚洲视频在线免费观看 | 九九热精品视频 | 成人在线国产 | 国产99久久| 久久精品国产一区二区三区不卡 | 色婷婷狠狠 | 欧美日韩中文在线 | 日韩欧美中文字幕在线视频 | 亚洲区日韩 | 日韩一区二区免费看 | 999成人网| 91麻豆精品国产91久久久资源速度 | 国产精品999| 麻豆av免费观看 | 亚洲成人高清 | 在线三级av | 久久手机免费视频 | 欧美日韩中文 | 日韩福利片 | 中文字幕日本视频 | 欧美三级三级三级爽爽爽 | 日韩欧美精品一区二区 | 超碰地址| 国产ai视频 | av三级在线播放 |