Home  >  Article  >  Web Front-end  >  Detailed explanation of the solution to the problem that the content of the select drop-down box in HTML is not fully displayed and partially covered

Detailed explanation of the solution to the problem that the content of the select drop-down box in HTML is not fully displayed and partially covered

高洛峰
高洛峰Original
2018-05-19 09:10:364572browse

The content in the select drop-down box in HTML was too long, causing part of it to be covered. I tried various methods but had no clue. Finally, I added the title attribute to the option and found that the problem was solved. Today, I encountered such a problem: the content in the drop-down box in the query column was too long, causing part of it to be covered.
I checked some information, some said to use function control, some said to use event control, some couldn't understand, and some were too complicated to implement. Later, I asked my colleague if there was any simple method. He told me to add the title attribute to the option, so I tried his method and finally found that this method worked. In this way, I want to record it to prevent myself from forgetting.
1. The specific examples are as follows

The code is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>HTML中的select下拉框内容显示不全的解决办法</title> 
<style type="text/css"> 
#area option{ 
width:140px; 
} 
</style> 
</head> 
<body style="width:80%; height:100px; text-align:center;"> 
<p id="p_select"> 
<label for="area">字母:</label> 
<select id="area" name="area" style="width:150px;"> 
<option value="0">全部</option> 
<option value="1" title="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA">AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</option> 
<option value="2" title="BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB">BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB</option> 
<option value="3" title="CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC">CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC</option> 
<option value="4" title="DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD">DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD</option> 
<option value="5" title="EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE">EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE</option> 
<option value="6" title="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF">FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</option> 
<option value="7" title="GGGGGGGGGGGGGGGGGGGGGGGGGGGGGG">GGGGGGGGGGGGGGGGGGGGGGGGGGGGGG</option> 
<option value="8" title="HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH">HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH</option> 
<option value="9" title="IIIIIIIIIIIIIIIIIIIIIIIIIIIIII">IIIIIIIIIIIIIIIIIIIIIIIIIIIIII</option> 
</select> 
</p> 
</body> 
</html>

2. Example results

Detailed explanation of the solution to the problem that the content of the select drop-down box in HTML is not fully displayed and partially covered
3.Dynamic data

The code is as follows:

<p id="p_select"> 
<label for="area">省份:</label> 
<select id="area" name="area" style="width:150px;"> 
<option value="0">全部</option> 
<c:forEach items="${list}" var="area"> 
<option value="${area.areaCode}" title="${area.areaName}">${area.areaName}</option> 
</c:forEach> 
</select> 
</p>

For more detailed explanations on the solution to the problem that the content of the select drop-down box in HTML is not fully displayed and partially covered, please pay attention to the PHP Chinese website for related articles!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn