Search code examples
htmlcsspositioning

positioning a div right and left simultaneously


i'm trying to make a div have a width using the absolute positioning and it work fine in google chrome but in fierfox it doesnt. why is there a conflict ? i tried the exact same code in both browser and on fierfox doesnt reconize it.

   <!DOCTYPE HTML>
<html >
    <head>
        <meta charset="utf-8"/>
        <title>Kelma</title>
        <link rel="stylesheet" href="style.css" />
    </head>
    <body>

            <input type="text" id="center" />
    </body>
</html>

and this is the css file

#center{
    position: absolute;
    left:50px;
    right: 50px;
}

Solution

  • Take a look at this:

    <!DOCTYPE HTML>
    <html >
        <head>
            <meta charset="utf-8"/>
            <title>Kelma</title>
            <link rel="stylesheet" href="style.css" />
            <style>
                #wrapper
                {
                   position: absolute;
                   left:50px;
                   right: 50px;
                }
                #center
                {
                   width:100%;
                }
            </style>
        </head>
        <body>
            <div id="wrapper">
                   <input type="text" id="center" value="test" />
            </div>
        </body>
    </html>
    

    i wrapper the input with a div, and i applied the styling to the div, and 100% width to the input.