2017-03-07 82 views
1

我有搜索到很多的在這裏,但仍然沒有解決我的問題,我有問題,我的數據是動態的,有的長,有的短,短則沒關係,但對於長的文本,我想它是喙線。但它沒有休息,得出同樣的行線(做重複文本)。請幫助我,這本我的HTMLCSS如何突破線時長數據

Company name: <a id="com_name">REGIONAL COMMUNITY FORESTRY TRAINING CENTER FOR ASIA AND PACIFIC (RECOFTC)</a> 

和我的CSS:

#com_name{ 
    font-size: 12px; 
    position: fixed; 
    width: 50%; 
    word-break: break-all; 
    white-space: normal 
} 

但我的結果是這樣enter image description here

我想要什麼

Company name: REGIONAL COMMUNITY FORESTRY TRAINING CENTER FOR ASIA AND 
       PACIFIC (RECOFTC) 
+1

使用行高度:28px; – user7357089

+0

是我的問題,通過附加'線height' – koe

回答

1

在你的CSS設置line-height

#com_name{ 
    font-size: 12px; 
    position: fixed; 
    width: 50%; 
    word-break: break-all; 
    white-space: normal; 
    line-height: 20px; 
} 
+0

是的,感謝所用'線height' – koe

2

使用line-height: 2;line-height: 20px;

實施例 - 1:使用line-height: 2;

#com_name{ 
    font-size: 12px; 
    position: fixed; 
    width: 50%; 
    word-break: break-all; 
    white-space: normal; 
    line-height: 2; 
} 

#com_name{ 
 
    font-size: 12px; 
 
    position: fixed; 
 
    width: 50%; 
 
    word-break: break-all; 
 
    white-space: normal; 
 
    line-height: 2; 
 
}
Company name: <a id="com_name">REGIONAL COMMUNITY FORESTRY TRAINING CENTER FOR ASIA AND PACIFIC (RECOFTC) </a>

例 - 2:使用line-height: 20px;

#com_name{ 
    font-size: 12px; 
    position: fixed; 
    width: 50%; 
    word-break: break-all; 
    white-space: normal; 
    line-height: 20px; 
} 

#com_name{ 
 
    font-size: 12px; 
 
    position: fixed; 
 
    width: 50%; 
 
    word-break: break-all; 
 
    white-space: normal; 
 
    line-height: 20px; 
 
}
Company name: <a id="com_name">REGIONAL COMMUNITY FORESTRY TRAINING CENTER FOR ASIA AND PACIFIC (RECOFTC) </a>

+0

解決它幫助我所用'線height' – koe

1

我也面臨這個problem.You可以使用word-wrap,看我下面的例子。

Like this you will get

#dob{ 
 
\t font-size: 11px; 
 
\t display: inline-block !important;*/ 
 
\t vertical-align: middle !important;*/ 
 
\t color: #365899; 
 
    cursor: pointer; 
 
    word-wrap: break-word; 
 
    width: 158px; 
 
}
<div id="selectDob"> 
 
<select label="Day" name="birthdat_day" class="days" id="selectDateOfBirth"> 
 
<option value="0" selected="1">Day</option> 
 
</select> 
 
<select label="Month" name="birthday_month" class="months" id="selectDateOfBirth"> 
 
<option value="0" selected="1">Month</option> 
 
</select> 
 
<select label="Year" name="birthday_year" class="years" id="selectDateOfBirth"> 
 
<option value="0" selected="1">Year</option> 
 
</select> 
 
<div id="dobContent"> 
 
    <a href="#" id="dob" data-toggle="popover">Why do I need to provide my date of birth?</a> 
 
</div> 
 
</div>

2

嘗試......

.class_name { 
    word-wrap: break-word; 
} 

謝謝

2

使用

#com_name{ 
    word-break: break-word; 
    white-space: normal 
} 
1
<html> 
    <head> 
    <style> 
    /*anchor tag*/ 
    #com_name{ 
     font-size: 12px; 
     width: 50%; 
     white-space: normal 
    } 

    /*set width for first p tag*/ 
    .first{ 
     width:8%; 
    } 

    /*set width, margin-top and margin-left for second p tag*/ 
    .second{ 
     margin-left:8%; 
     margin-top:-33px; 
     width:32%; 
    } 
    </style> 
    </head> 
    <body> 
    <p class="first">Company name:</p> 
    <p class="second"> <a id="com_name">REGIONAL COMMUNITY FORESTRY TRAINING CENTER FOR ASIA 
AND PACIFIC (RECOFTC)</a></p> 
    </body> 
    </html> 
+0

我的問題解決了一個小的解釋將是有益的 –