css如何實(shí)現(xiàn)字母不到一行就換行

這篇文章主要介紹“css如何實(shí)現(xiàn)字母不到一行就換行”,在日常操作中,相信很多人在css如何實(shí)現(xiàn)字母不到一行就換行問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”css如何實(shí)現(xiàn)字母不到一行就換行”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!

成都創(chuàng)新互聯(lián)公司是一家朝氣蓬勃的網(wǎng)站建設(shè)公司。公司專注于為企業(yè)提供信息化建設(shè)解決方案。從事網(wǎng)站開發(fā),網(wǎng)站制作,網(wǎng)站設(shè)計(jì),網(wǎng)站模板,微信公眾號開發(fā),軟件開發(fā),小程序開發(fā),十多年建站對隧道混凝土攪拌車等多個行業(yè),擁有多年的網(wǎng)站營銷經(jīng)驗(yàn)。

css字母不到一行就換行的方法:1、給元素添加“word-break:break-word;”樣式,使其以單詞為單位換行;2、給元素添加“word-break:break-all;”樣式,使其以字母為單位換行。

css如何實(shí)現(xiàn)字母不到一行就換行

本教程操作環(huán)境:windows7系統(tǒng)、CSS3&&HTML5版、Dell G3電腦。

css字母不到一行就換行的方法

打開一個html代碼頁面,創(chuàng)建兩個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é)果:

css如何實(shí)現(xiàn)字母不到一行就換行

css如何實(shí)現(xiàn)字母不到一行就換行

以上便是兩種不同的換行方式。

到此,關(guān)于“css如何實(shí)現(xiàn)字母不到一行就換行”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!

網(wǎng)站題目:css如何實(shí)現(xiàn)字母不到一行就換行
網(wǎng)頁網(wǎng)址:http://muchs.cn/article18/gepjgp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計(jì)、外貿(mào)網(wǎng)站建設(shè)、品牌網(wǎng)站設(shè)計(jì)、定制網(wǎng)站關(guān)鍵詞優(yōu)化、靜態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

綿陽服務(wù)器托管