我难以在页面顶部选择框的样式,看起来像下面的可折叠DIV ..当我的API返回2个对象时,我只需要进行这种外观修改(当有2个选项时框)。我也不想使用一个插件,它允许你给按钮一个onClick功能来模仿下拉选择,如果可以的话 - 需要大量的重新开发等。
当有两个选项时,我想把它设计为吮吸:
white plus sign added to the left of the select box
以下是我用来设置按钮样式的一些代码:
var innerdiv = $('<div class="acc_list" data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme="b" ></div>');
这会将可折叠功能添加到DIV。
我已经尝试添加到DIV里面,我有里面的选择框,但它似乎将它添加到右下角。
<div id="selectBoxContainer" data-role="fieldcontain">
<select id="selectbox" class="combobox" name="selectbox" onchange="PolicyChange('selectbox')"></select>
</div>
我检查数据是否包含两个对象,如果是这样的话:
if (parseInt(policies.length) > 1)
{
select.removeClass('combobox');
changeBox.addClass('ui-collapsible-heading-toggle ui-btn ui-btn-icon-left ui-icon-plus ui-btn-b');
}
以下是我的CSS页面:
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
* {
-webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */
}
body {
-webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */
-webkit-text-size-adjust: none; /* prevent webkit from resizing text to fit */
-webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */
background-color: #E4E4E4;
background-image: linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
background-image: -webkit-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
background-image: -ms-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
background-image: -webkit-gradient( linear, left top, left bottom, color-stop(0, #A7A7A7), color-stop(0.51, #E4E4E4) );
background-attachment: fixed;
height: 100%;
margin: 0px;
padding: 0px;
width: 100%;
background: transparent !important;
/* 170px x 200px */
background-repeat: no-repeat;
font-size: 15px;
background-position: center top;
background-size: 100% !important;
}
/* Portrait layout (default) */
.app {
position: absolute; /* position in the center of the screen */
height: 50px; /* text area height */
width: 225px; /* text area width */
text-align: center;
padding: 180px 0px 0px 0px; /* image height is 200px (bottom 20px are overlapped with text) */
margin: -115px 0px 0px -112px; /* offset vertical: half of image height and text area height */
/* offset horizontal: half of text area width */
}
/* Landscape layout (with min-width) */
@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) {
.app {
background-position: left center;
padding: 75px 0px 75px 170px; /* padding-top + padding-bottom + text area = image height */
margin: -90px 0px 0px -198px; /* offset vertical: half of image height */
/* offset horizontal: half of image width and text area width */
}
}
h1 {
}
.event {
border-radius: 4px;
-webkit-border-radius: 4px;
color: #FFFFFF;
font-size: 12px;
margin: 0px 30px;
padding: 2px 0px;
}
.event.listening {
background-color: #333333;
display: block;
}
.event.received {
background-color: #4B946A;
display: none;
}
@keyframes fade {
from {
opacity: 1.0;
}
50% {
opacity: 0.4;
}
to {
opacity: 1.0;
}
}
@-webkit-keyframes fade {
from {
opacity: 1.0;
}
50% {
opacity: 0.4;
}
to {
opacity: 1.0;
}
}
.centerize {
display: block;
margin: 0 auto;
text-align: center;
}
.img_grey {
display: block;
-webkit-filter: grayscale(100%);
}
.blink {
animation: fade 3000ms infinite;
-webkit-animation: fade 3000ms infinite;
}
.ui-btn.ui-input-btn, .ui-link.ui-btn {
display: inline-block;
vertical-align: bottom;
}
.ui-block-a, .ui-block-b, .ui-block-c {
text-align: center !important;
}
.ui-content {
}
div[data-role="footer"] {
}
div[data-role="footer"] .nav-glyphish-example .ui-btn .ui-btn-inner {
padding-top: 40px !important;
}
div[data-role="footer"] .nav-glyphish-example .ui-btn .ui-icon:after {
width: 30px !important;
height: 30px !important;
margin-left: 15px !important;
box-shadow: none !important;
-moz-box-shadow: none !important;
-webkit-box-shadow: none !important;
-webkit-border-radius: 0 !important;
border-radius: 0 !important;
}
#home.ui-btn-icon-top:after {
background-position: 10% 10%;
background-size: 100% 100% !important;
background-image: url('../img/home-white.png') !important;
background-repeat: no-repeat !important;
background-attachment: scroll !important;
}
#call.ui-btn-icon-top:after {
background-position: 10% 10%;
background-size: 100% 100% !important;
background-image: url('../img/contact-white.png') !important;
background-repeat: no-repeat !important;
background-attachment: scroll !important;
}
#settings.ui-btn-icon-top:after {
background-position: 10% 10%;
background-size: 100% 100% !important;
background-image: url('../img/settings-white.png') !important;
background-repeat: no-repeat !important;
background-attachment: scroll !important;
}
#panic.ui-btn-icon-top:after {
background-position: 10% 10%;
background-size: 100% 100% !important;
margin-top: 5px;
background-repeat: no-repeat !important;
background-attachment: scroll !important;
}
#panicafr.ui-btn-icon-top:after {
background-position: 10% 10%;
background-size: 100% 100% !important;
margin-top: 5px;
background-image: url('../img/panicafr.png') !important;
background-repeat: no-repeat !important;
background-attachment: scroll !important;
}
a#panic.panicAfr:after {
background-position: 10% 10%;
background-size: 100% 100% !important;
margin-top: 5px;
background-image: url('../img/panicafr.png') !important;
background-repeat: no-repeat !important;
background-attachment: scroll !important;
}
a#panic.panicEng:after {
background-position: 10% 10%;
background-size: 100% 100% !important;
margin-top: 5px;
background-image: url('../img/panic.png') !important;
background-repeat: no-repeat !important;
background-attachment: scroll !important;
}
a#panic.panicAfrSkip:after {
background-position: 10% 10%;
background-size: 100% 100% !important;
margin-top: 5px;
background-image: url('../img/panicgreyafr.png') !important;
background-repeat: no-repeat !important;
background-attachment: scroll !important;
}
a#panic.panicEngSkip:after {
background-position: 10% 10%;
background-size: 100% 100% !important;
margin-top: 5px;
background-image: url('../img/panicgrey.png') !important;
background-repeat: no-repeat !important;
background-attachment: scroll !important;
}
.ui-grid-b > .ui-block-a p, .ui-grid-b > .ui-block-b p, .ui-grid-b > .ui-block-c p {
margin: 5px 0 20px 0;
}
.backbutton {
background-image: url(../img/back.png);
background-repeat: no-repeat;
background-position: left;
padding-left: 25px !important;
background-size: auto 100%;
color: #0096ff !important;
background-color: transparent !important;
background-color: transparent !important;
border-color: transparent !important;
width: 0.6em;
height: 0.6em;
padding-top: 0.2em;
}
.loginbutton {
background-image: url(../img/login-skip.png);
background-repeat: no-repeat;
background-position: right;
padding-left: 25px !important;
background-size: auto 100%;
color: #0096ff !important;
background-color: transparent !important;
background-color: transparent !important;
border-color: transparent !important;
width: 10px;
height: 10px;
padding-top: 5px;
}
.logo {
text-align: center;
}
li {
padding-left: 2px;
}
.acc_list a:after {
border-radius: 4em !important;
width: 2.5em !important;
height: 2.5em !important;
left: 0.15em;
top: 1em;
}
div#backHeader * {
vertical-align: middle;
line-height: 1.5em;
}
.lbl-no-float {
float: initial !important;
}
div.loadingModal * {
}
div.loadingModal img {
margin-top: 2em;
}
.infoimg {
width: 1em;
height: 1em;
}
div.loadingModal p:after {
content: '...';
}
div.loadingModal p {
padding-left: 0.5em;
}
#img_login_skip {
position: absolute;
right: 0;
padding-right: 0.2em;
top: -0.35em;
}
div.ui-block-b.userInfo label {
display: block;
width: 100%;
text-align: left;
}
fieldset {
display: block;
margin-left: 2px;
margin-right: 2px;
padding-top: 0.35em;
padding-bottom: 0.625em;
padding-left: 0.75em;
padding-right: 0.75em;
border: 2px;
}
hr { width:100%; height:1px; background: #fff }
a.ui-collapsible-heading-toggle.ui-btn.ui-icon-plus.ui-btn-icon-left.ui-btn-b,
a.ui-collapsible-heading-toggle.ui-btn.ui-btn-icon-left.ui-btn-b.ui-icon-minus {
background-image: none !important;
background-color: rgb(237, 237, 237) !important;
}
.profileimagesection {
margin: 0 auto;
overflow: hidden;
margin-bottom: 1em;
}
.pressedIconsContainerInactive{
opacity: 1.0 !important;
-moz-opacity: 1.0 !important;
-webkit-opacity: 1.0 !important;
filter: alpha(opacity=100) !important; /*IE compatibility for Windows Phones (possihttp://localhost:59778/IntegriSure/css/index.cssbly needed)*/
}
.pressedIconsContainerActive{
opacity: 0.7 !important;
-moz-opacity: 0.7 !important;
-webkit-opacity: 0.7 !important;
filter: alpha(opacity=70); /*IE compatibility for Windows Phones (possibly needed)*/
}
/*.userProfilePic{
background-size:cover;
width: 40vw; /*use CSS3 viewports to keep size on Tablets*/
/* height: 25vh; /*use CSS3 viewports to keep size on Tablets*/
/* border: 1px solid #eee;
border-radius: 5px;
}*/
.inactiveLink {
pointer-events: none;
cursor: default;
}
.ui-icon-loading {
background: url('../img/loading-spin.svg') !important;
background-size: contain !important;
}
.ui-loader-default {
opacity: 1.0 !important;
}
.ui-btn-inline {
margin-right: 0 !important;
}
#claimstracking .ui-field-contain label:last-child{
width:auto;
}
.ui-listview a {
display: block;
/* max-width: 80%; */
word-wrap: break-word;
white-space: normal;
text-decoration: none;
}
#pressdetails #pressData * {
font-size: 12pt !important;
}
.toolbarinitial {
position: initial;
}
input.red{
background-color: #FF0000;
border-color: #F04040;
}
input.green{
background-color: #00FF00;
border-color: #8DFF1C;
}
尝试下面的响应后 - 我得到了白色加号,但是它在左下方 - 似乎无法将其与文本内联..很难在图像中看到但是十字架在那里但不是内联:
Top of the cross on the bottom left of the text
还有其他建议吗?
答案 0 :(得分:0)
jQM选择小部件具有用于将图标放在左侧以及用于选择要显示的图标(data-iconpos="left" data-icon="plus"
)的属性:
<div id="selectBoxContainer" data-role="fieldcontain">
<select id="selectbox" class="combobox" name="selectbox" data-iconpos="left" data-icon="plus" >
<option val="1">Option 1</option>
<option val="2">Option 2</option>
</select>
</div>
然后,如果您想隐藏图标后面的灰色磁盘,只需白色加显示,请使用此CSS:
#selectBoxContainer .ui-select .ui-btn-icon-left::after {
background-color: transparent !important;
}
<强> DEMO 强>