您好,登錄后才能下訂單哦!
這篇文章主要介紹“css如何實(shí)現(xiàn)字母不到一行就換行”,在日常操作中,相信很多人在css如何實(shí)現(xiàn)字母不到一行就換行問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”css如何實(shí)現(xiàn)字母不到一行就換行”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!
css字母不到一行就換行的方法:1、給元素添加“word-break:break-word;”樣式,使其以單詞為單位換行;2、給元素添加“word-break:break-all;”樣式,使其以字母為單位換行。
本教程操作環(huán)境:windows7系統(tǒng)、CSS3&&HTML5版、Dell G3電腦。
css字母不到一行就換行的方法
打開一個(gè)html代碼頁面,創(chuàng)建兩個(gè)div標(biāo)簽并輸入一段英文語句。分別設(shè)置按字母自動換行和按單詞自動換行兩種css樣式。
word-break:break-word;//表示以單詞為單位換行, word-break:break-all;//表示以字母為單位換行。
代碼如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> .aa{ width:150px; word-break:break-word; } .bb{ width:150px; word-break:break-all; } </style> </head> <body> <div class="aa">When summer comes, unlike most people, I will be very excited, because I like summer very much. People don’t like summer because of its hot weather, which makes people sweat all the time. But summer is my favorite season, I can wear fewer clothes. I like to wear short jeans and a T-shirt, I feel so free.</div> <div class="bb">When summer comes, unlike most people, I will be very excited, because I like summer very much. People don’t like summer because of its hot weather, which makes people sweat all the time. But summer is my favorite season, I can wear fewer clothes. I like to wear short jeans and a T-shirt, I feel so free.</div> </body> </html>
輸出結(jié)果:
以上便是兩種不同的換行方式。
到此,關(guān)于“css如何實(shí)現(xiàn)字母不到一行就換行”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注億速云網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。