简体   繁体   中英

Formatting jQuery Mobile Labels and their input boxes

I've got a label and an input box in jquery and wish to format it into a certain but that is looking to be impossible. Here is a picture of what I am looking to achieve:

我要做什么

Here is my HTML of what I currently have:

<div data-role="fieldcontain" style="width:100%;">
        <label for="name" style="background:yellow;color:black;width:5%;border-top-left-radius:10px;border-bottom-left-radius:10px;padding-right:0px;height:5%;">Text Input</label>
        <input type="text" name="name" id="name" value="" style="border-top-left-radius:0px;border-bottom-left-radius:0px;width:93%"/>
</div>

But I keep getting this:

在此处输入图片说明

How do I get the input box to fill the screen ie have a width of 93% and have no top and bottom border radius? The other problem is the Text Input labels height? what doesn't height:5% work? Please help?

You could set data-role="none" on the input and then use regular CSS.

Here is a DEMO

    <div id="specialCont">
        <div>
            <label for="pub_url">Text Input</label>
            <input data-role="none" type="text" id="pub_url" name="pub_url" value="http://cssdeck.com" />
        </div>
    </div>

#specialCont {
    background: #165FD1;
    padding: 10px  4px;
    width: 100%;
    margin: 0 auto;
    border: 1px solid #ccc;
}
#specialCont div {
    overflow: hidden;
}
#specialCont label, #specialCont input {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
#specialCont label {
    font-weight: normal;
    background: linear-gradient(#FFFF00, #D8E404);
    padding: 5px;
    color: #333;
    border: 1px solid #d4d4d4;
    border-right: 0;
    border-bottom-left-radius:2em;
    border-top-left-radius: 2em;    
    line-height: 24px;
    width: 20%;
    float: left;
    text-align: center;
    cursor: pointer;
    white-space:nowrap;
}
#specialCont input {
    width: 80%;
    padding: 8px;
    border: 1px solid #d4d4d4;
    border-bottom-right-radius: 2em;
    border-top-right-radius: 2em;
    line-height: 18px;
    float: right;
    margin-top: 0px;
    box-shadow: inset 0px 2px 2px #ececec;
}
#specialCont input:focus {
    outline: 0;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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