Solution to the problem of incomplete display of select drop-down box content in HTML and partial coverage

Solution to the problem of incomplete display of select drop-down box content in HTML and partial coverage
Today, I encountered a problem: the content in the drop-down box in the query bar was too long, causing part of it to be covered.

I looked up some information, some said to use function control, some said to use event control, some I couldn't understand, and some were too complicated to implement. Later, I asked a colleague if there were some simple methods. He told me to add the title attribute in the option. So I tried his method and finally found that this method works. So, I want to write it down to avoid forgetting it.

1. The specific examples are as follows

Copy code
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>Solution to incomplete display of select drop-down box content in HTML</title>
<style type="text/css">
#area option{
width:140px;
}
</style>
</head>
<body style="width:80%; height:100px; text-align:center;">
<div id="div_select">
<label for="area">Letters:</label>
<select id="area" name="area" style="width:150px;">
<option value="0">All</option>
<option value="1" title="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA">AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</option>
<option value="2" title="BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB">BBBBBBBBBBBBBBBBBBBBBBBBBBBB</option>
<option value="3" title="CCCCCCCCCCCCCCCCCCCCCCCCCCCC">CCCCCCCCCCCCCCCCCCCCCCCCCC</option>
<option value="4" title="DDDDDDDDDDDDDDDDDDDDDDDDDDDD">DDDDDDDDDDDDDDDDDDDDDDDDDDDD</option>
<option value="5" title="EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE">EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE</option>
<option value="6" title="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF">FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</option>
<option value="7" title="GGGGGGGGGGGGGGGGGGGGGGGGGGGGGG">GGGGGGGGGGGGGGGGGGGGGGGGGGG</option>
<option value="8" title="HHHHHHHHHHHHHHHHHHHHHHHHHHHHH">HHHHHHHHHHHHHHHHHHHHHHHHH</option>
<option value="9" title="IIIIIIIIIIIIIIIIIIIIIIIIIIIIII">IIIIIIIIIIIIIIIIIIIIIIIIIII</option>
</select>
</div>
</body>
</html>

2. Example Results



3. Dynamic Data

Copy code
The code is as follows:

<div id="div_select">
<label for="area">Province:</label>
<select id="area" name="area" style="width:150px;">
<option value="0">All</option>
<c:forEach items="${list}" var="area">
<option value="${area.areaCode}" title="${area.areaName}">${area.areaName}</option>
</c:forEach>
</select>
</div>

<<:  The concrete implementation of JavaScript exclusive thinking

>>:  Implementation of MySQL Shell import_table data import

Recommend

Pure CSS to achieve automatic rotation effect of carousel banner

Without further ado, let’s get straight to the co...

12 Javascript table controls (DataGrid) are sorted out

When the DataSource property of a DataGrid control...

How to use Navicat to operate MySQL

Table of contents Preface: 1. Introduction to Nav...

Reasons why MySQL 8.0 statistics are inaccurate

Preface Whether it is Oracle or MySQL, the new fe...

WeChat applet custom scroll-view example code

Mini Program Custom Scroll-View Scroll Bar Withou...

Use node-media-server to build a simple streaming media server

Record some of the processes of using node-media-...

CSS3 implementation example of rotating only the background image 180 degrees

1. Mental Journey When I was writing the cockpit ...

Detailed explanation of js's event loop event queue in the browser

Table of contents Preface Understanding a stack a...

Div nested html without iframe

Recently, when doing homework, I needed to nest a ...

MySQL full-text search usage examples

Table of contents 1. Environmental Preparation 2....

The difference between name and value in input tag

type is the control used for input and output in t...