【发布时间】:2018-11-28 12:51:48
【问题描述】:
我想让选择框的每个首字母都大写,但我的代码只适用于小写和大写。如何使每个单词的首字母大写?大写是否适用于 crome 浏览器或我的代码有误?
我尝试了更多时间,但它仅适用于大写和小写,不适用于大写
这是我的 PHP 代码:
<select name="hotel_name1" id="hotel_name1" class="select-drop">
<option value disabled selected style="color:gray">Select Hotel</option>
<?php
while ($row=mysql_fetch_array($result)) {
?>
<option value="<?php echo $row["postid"]; ?>"><?php echo $row["hotel_name"]; ?></option>
<?php
}
?>
</select>
CSS:
select {
height: 1.4em; /* show only one option when not focused */
}
option {
text-transform: lowercase; /* change to lowercase */
padding-right: 2em; /* the select's width is based on width of its longest non-transformed ... */
/* option. padding ensures that option is completely visible */
display: none; /* hide all options by default (see below) */
}
option:first-letter {
text-transform: uppercase; /* change first letter to uppercase */
}
option:checked, select:focus option {
display: block; /* show selected option, or show all options when the select is focused */
}
【问题讨论】:
-
似乎是什么问题 -> jsfiddle.net/yLehr95z?
-
没有人应该再编写带有
mysql_的代码了。请切换到mysqli_功能。通过 php 与 css 实现所需的调整会简单得多。