简体   繁体   English

HTML选择剪切文本

[英]HTML Select cutting text off

Ok, as usual, I come here as a last resort after pulling what's left of my hair out and not finding the solution online. 好的,像往常一样,我把剩下的头发拉出来,没有在网上找到解决方法,这是我的最后选择。

Have a simple table with one row and three cells. 有一个简单的表,其中包含一行和三个单元格。 Inside two cells are fieldsets (I like the look) containing a <select> and two buttons. 在两个单元格内是包含<select>和两个按钮的<select> (我喜欢外观)。 Everything looks as I want it, except that the text for the options are cut off. 一切看起来都与我想要的一样,只是选项的文本被截断了。

I've tried resizing the select, but can't find any reference on resizing the option itself. 我尝试过调整选择的大小,但是找不到有关调整选项本身大小的任何参考。

What am I doing wrong? 我究竟做错了什么?

The HTML: HTML:

 <div id='tabs-1' style='width: 95%;'> <table style='width: 98%; margin-left: auto; margin-right: auto;'> <tr> <td style='width: 33%;text-align: center;'> <fieldset style='height: 300px;width: 90%;'> <legend>Manual</legend> <br> <div style='text-align: center;'> <a href="#" onclick='getPage("SheriffManual")' target="_self"> <img src="images/manualIcon.jpg" alt='Manual' height="65"> <br> Sheriff's Policy and Procedure </a> </div> </fieldset> </td> <td style='width: 33%;text-align: center;'> <fieldset style='height: 300px;width: 90%;'> <legend>Memorandum</legend> <br> <div style='width: 100%;" text-align: center;'> <select style='width: 90%;' size="8" id='selSheriffMemorandum' name="selSheriffMemorandum" value=""> <option value='memorandum/MINIMUM APPLICANT STANDARDS FOR DETENTION, PEACE OFFICERS AND TELECOMMUN.pdf'>Minumum Applicant Standards</option> <option value='memorandum/Memorandum EMPLOYEE SMOKING AREAS.pdf'>Employee Smoking Areas</option> </select> <br><br> <div style='float: left; margin-left: 75px;'> <button>View</button> </div> <div style='float: right; margin-right: 75px;'> <button>Download</button> </div> </div> </fieldset> </td> <td style='width: 33%;text-align: center;'> <fieldset style='height: 300px;width: 90%;'> <legend>Directives</legend> <br> <select size='8' style='width: 90%' id='selSheriffDirectives' name='selSheriffDirectives' value=''> <option value='directives/SHERIFFS DIRECTIVE NO 2015-09-01 WORK PLACE VIOLENCE.pdf'>Workplace Violence</option> <option value='directives/Directive ANNUAL TUBERCULOSIS SCREENING.pdf'>Annual Tuberculosis Screening</option> <option value='directives/Sheriffs Directive No. 02-03 - Bereavement Leave.pdf'>Bereavement Leave</option> <option value='directives/SHERIFFS DIRECTIVE Mental Health Pre-Screening and Diversion NO 2015-01.pdf'>Mental Health Pre-Screening</option> </select> <br><br> <div style='float: left; margin-left: 75px;'> <button>View</button> </div> <div style='float: right; margin-right: 75px;'> <button>Download</button> </div> </fieldset> </td> </tr> </table> </div> 

The result: 结果:

选择框切除文本

UPDATE: I took out all the CSS and javascript for the page, and the select renders as expected. 更新:我取出了页面的所有CSS和javascript,并且select呈现了预期的效果。 After putting everything back in, I realized that it was jquery.ui.js causing the problems -- I'm using jquery's tabs and it's setting the <select> option width the same as the tab widths. 将所有内容放回去之后,我意识到是导致问题的jquery.ui.js -我正在使用jquery的选项卡,并且将<select>选项宽度设置为与选项卡宽度相同。 Now I just have to find out what/how I need to override jquery. 现在,我只需要找出我需要/如何重写jquery。

How about adding a scrollbar to your select elements? 如何在您的选择元素中添加滚动条?

<select style='width: 90%; overflow: scroll' size="8" id='selSheriffMemorandum' name="selSheriffMemorandum" value="">
...
</select>

Change the height or padding of <option> 更改<option>heightpadding

option {
    height:8px;
    padding:8px;
}

Turns out there's a simple fix (courtesy of Select box truncating text when body font size changed via javascript on document ready in IE 9 ): 事实证明,有一个简单的解决方法( 当通过IE 9中准备好的文档中的javascript更改正文字体大小时选择框会截断文本 ):

$('select').append(' ');

Forces the select to be redrawn. 强制重选选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM