当我使用transform: rotate()
整个button
旋转时,而不仅仅是图像,我想创建一个div
来包装图像,旋转这个div
并将其放置在button
上方,但感觉不对,必须有另一种方法。
select{
border: 1px solid #ccc;
padding: 5px 35px 5px 5px;
width:150px;
height: 40px;
background-color: #eee;
color: black;
font-size: 16px;
-moz-appearance: none;
-webkit-appearance: none;
appearance: none;
background: url(https://image.flaticon.com/icons/svg/660/660570.svg) 90% / 12% no-repeat #eee ;
}
<select>
<optgroup label="Ultra Secret">
<option>007</option>
<option selected>MIB</option>
<option>u mom Alien</option>
<option>no u</option>
</optgroup>
<optgroup label="Something Important">
<option>Item 1</option>
<option>Item 2</option>
<option>Item 3</option>
<option>Item 4</option>
<option>Item 5</option>
</optgroup>
</select>
您需要从一个图像切换到另一个图像,旋转不适用于背景图像
例
select{
border: 1px solid #ccc;
padding: 5px 35px 5px 5px;
width:150px;
height: 40px;
background-color: #eee;
color: black;
font-size: 16px;
-moz-appearance: none;
-webkit-appearance: none;
appearance: none;
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pg0KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPg0KPHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJDYXBhXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgNTEyLjAwMyA1MTIuMDAzIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1MTIuMDAzIDUxMi4wMDM7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxnPg0KCTxwb2x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DItNC41MzIsMi41MS04LjY5LDYuNTIyLTEwLjc5N2M0LjAxMi0yLjEwNyw4Ljg2Mi0xLjgxNCwxMi41OTEsMC43NjFsMzUzLjUyNCwyNDMuODFjMy4yOTksMi4yNzYsNS4yNjgsNi4wMjgsNS4yNjgsMTAuMDM2DQoJCWMwLDQuMDA4LTEuOTY5LDcuNzU5LTUuMjY4LDEwLjAzNkw4Ni4xNjIsNTA5Ljg0OUM4NC4xMjYsNTExLjI1MSw4MS43MTIsNTEyLjAwMyw3OS4yNCw1MTIuMDAzeiBNOTEuNDMsMzUuNDA4djQ0MS4xOQ0KCQlsMzE5Ljg2My0yMjAuNTk1TDkxLjQzLDM1LjQwOHoiLz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjwvc3ZnPg==) 90% / 12% no-repeat #eee ;
<select>
<optgroup label="Ultra Secret">
<option>007</option>
<option selected>MIB</option>
<option>u mom Alien</option>
<option>no u</option>
</optgroup>
<optgroup label="Something Important">
<option>Item 1</option>
<option>Item 2</option>
<option>Item 3</option>
<option>Item 4</option>
<option>Item 5</option>
</optgroup>
</select>