多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

中國最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2

css教程

CSS 教程

CSS 響應式設計

CSS實例

拓展閱讀

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

閱讀 (2144)

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


注冊表單


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 : 未實現

inter-cluster : 調整文本無詞間空格的行。這種模式的調整是用于優化亞洲語言文檔的

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

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

kashida : 通過拉長選定點的字符調整文本。這種調整模式是特別為阿拉伯腳本語言提供的。需要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;/*調整文本,以防止使用兩端對齊之后字間距過大*/ 
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元素,并應用樣式。另外,對于中文還必須用空格隔開漢字,否則也沒有兩端對齊的效果。英文每個單詞都有空格隔開,所以沒問題。
關閉
程序員人生
主站蜘蛛池模板: 欧美喷| 在线观看麻豆国产精品 | 激情综合五月天丁香婷婷 | 国产视频 每日更新 | 日本xx18护土 | 亚洲国产精品乱码在线观看97 | 精品自拍视频在线观看 | 久久99精品久久久久久综合 | 一级a毛片免费观看久久精品 | 免费乱码中文字幕网站 | 午夜影院在线免费观看 | 欧美一级黄色片视频 | 日韩精品视频一区二区三区 | 国产麻豆剧看黄在线观看 | 欧美xart系列高清在线视频 | 狠狠躁天天躁夜夜躁夜天战 | 激情春色 | 精品72久久久久久久中文字幕 | 国产精欧美一区二区三区 | 亚洲黄色a| 伊人福利网 | 毛色毛片免费观看 | 亚洲免费黄色网址 | 欧美日韩加勒比一区二区三区 | 午夜肉伦伦影院在线观看 | 中文字幕乱码中文乱码综合 | tube日本xxxx69| 香蕉tv亚洲专区在线观看 | 亚洲国产成人久久一区www妖精 | 美女福利片 | 美女牲交毛片一级视频 | 日本黄色网址大全 | 日韩在线一区二区三区视频 | 成人永久福利免费观看 | 在线免费看a爱片 | 国产欧美久久一区二区 | v片在线播放 | 日韩人成 | 五月激情婷婷综合 | 国产亚洲一区二区三区不卡 | 国产精品亚洲综合一区 |