Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS HTML5 date picker won't accept width: 100%;

I have a html5 date picker in my form for a mobile version of my site. All my text inputs are set to width:100% and its parent td is set to padding-right:15px to make it fit. This means my fields are nicely formatted and adjust to always fill up half of the container when the orientation of the device changes. However the date picker does not behave in the same way, can anyone help?

Form:

<form method="get" action="home">
<table id="form">
<tr><td>
<input type="text" name="Title" class="tbox" placeholder="Title" />
</td><td>
<input type="text" name="Genre" class="tbox" placeholder="Genre" />
</td></tr>
<tr><td>
<input type="text" name="Location" class="tbox" placeholder="Location" />
</td><td>
<input type="date" name="Date" class="tbox" placeholder="DD/MM/YY" />
</td></tr>
<tr><td>
<input type="text" name="postcode" class="tbox" id="postcode" placeholder="Postcode" />
</td><td>
<input type="number" name="radius" class="tbox" placeholder="Mile Radius" /><br />
</td></tr>
</table>
<input type="submit" value="Search" />
</form>

Relevant CSS:

.tbox {
background-color: #a1c9ff;
border: 1px solid #003f94;
width: 100%;
height: 30px;
margin: 3px 2px;
padding: 0 5px;
border-radius: 15px;
font-size: 18px;
float: left;
}

table#form tr td {
overflow: hidden;
padding-right: 15px;
}
like image 786
cainy393 Avatar asked May 02 '13 17:05

cainy393


People also ask

How can change date format in dd mm yyyy in HTML?

To set and get the input type date in dd-mm-yyyy format we will use <input> type attribute. The <input> type attribute is used to define a date picker or control field. In this attribute, you can set the range from which day-month-year to which day-month-year date can be selected from.

Does Safari support a date picker?

Note: Date and time input types is Partially Supported on Safari 15, which means that any user who'd be accessing your page through Safari 15 can see it perfectly.

Are there any style options for the html5 date picker?

Currently, there is no cross browser, script-free way of styling a native date picker. As for what's going on inside WHATWG/W3C... If this functionality does emerge, it will likely be under the CSS-UI standard or some Shadow DOM-related standard.

Which HTML tag is used to make a date picker?

The <input type="date"> defines a date picker. The resulting value includes the year, month, and day.


2 Answers

.tbox {  
    min-width:100%; 
}  
table#form {    
    width:100%;  
}

use width 100% for table#form and min-width:100% for .tbox, i hope this could solve your problem. have updated the jsfiddle http://jsfiddle.net/brfQf/1/

like image 170
Dinesh Kumar DJ Avatar answered Oct 09 '22 15:10

Dinesh Kumar DJ


This css style fixes the problem in mobile Safari:

-webkit-appearance: none;

However, it changes input appearance.

like image 38
Ivan Nikitin Avatar answered Oct 09 '22 14:10

Ivan Nikitin