Note that there are some explanatory texts on larger screens.

plurals
  1. POCenter form with display:table-cell
    primarykey
    data
    text
    <p>I have a submit button inside a form-tag. This form tag has some css-propertys:</p> <ol> <li>On Desktop it has a fixed with</li> <li>On mobile devices it has a percentage-width</li> </ol> <p>The problem is, that the submit button inside the form has width:auto; and margin:0 auto; so that it´s centered inside the form-tag. But webkit (mobile safari and safari) doesn´t understand that. In those browser the submit button is not centered but on the left side. So I wrote a jquery script which calculates the width and sets it to the submit button (instead of width:auto). That was the fix.</p> <p>I made a research and now I know, that I could use display:table-cell; in the form tag, which will center the content (the submit button) BUT: that means that I can not center the form itself. So my question is, how to modify the code below so that the form is centered inside the wrapper and the submit button inside the form?</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; #wrap{ width:1000px; background:red; } form { height:100px; width:500px; margin:0 auto; display:table-cell; border:1px solid black; text-align:center; vertical-align:middle; -webkit-box-align: center; } form input[type=submit], form input[type="button"], form input[type="reset"], form button { width:auto; min-width:40%; height:32px; margin:20px auto; line-height:14px; padding:9px 15px; background-color:#617798; border:0; font-size:14px; color:#FFFFFF; text-align:center; vertical-align:middle; -webkit-box-align: center; /* Border-Radius */ -webkit-border-radius:5px; -moz-border-radius:5px; border-radius:5px; -khtml-border-radius:5px; -o-border-radius:5px; cursor:pointer; display:inline; /* iPad-Button-Reset:*/ -webkit-appearance:none; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="wrap"&gt; &lt;h1&gt;Titel Blafasel&lt;/h1&gt; &lt;form&gt; &lt;input type="submit" value="Submit" /&gt; &lt;/form&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload