0

嗨,我在这里粘贴我的页面代码,因为我有一张背景图片。在那我需要放按钮。当我做放大和缩小按钮从位置移动。

<html>
<head>
    <style type="text/css">
        body
        {   
            background:SteelBlue url('BG_BLUE_NEW.jpg') no-repeat center center;
        }
        .login
        {
            margin-top:300px;
            height:300px
        }
    </style>
</head>
<body>
    <div class="container">
    <div class="login">
        <form style="padding-left:370px;margin-bottom:0px;">
            <INPUT TYPE="button" style="background-color:SteelBlue;width:100px;height:30px;font-size:150%;margin-bottom:10px" VALUE="Submit" onClick="window.open('http://www.google.com','_blank');"><br>
            <INPUT TYPE="button" style="background-color:SteelBlue;width:100px;height:30px;font-size:150%;margin-bottom:10px" VALUE="Submit" onClick="window.open('http://www.google.com','_blank');"><br>
            <INPUT TYPE="button" style="background-color:SteelBlue;width:100px;height:30px;font-size:150%;margin-bottom:10px" VALUE="Submit" onClick="window.open('http://www.google.com','_blank');"><br>
            <INPUT TYPE="button" style="background-color:SteelBlue;width:100px;height:30px;font-size:150%;margin-bottom:10px" VALUE="Submit" onClick="window.open('http://www.google.com','_blank');"><br>
            <INPUT TYPE="button" style="background-color:SteelBlue;width:100px;height:30px;font-size:150%;margin-bottom:10px" VALUE="Submit" onClick="window.open('http://www.google.com','_blank');"><br>
        </form>
    </div>
    </div>
</body>
</html>
4

1 回答 1

0

看看这个:

<html>
<head>
    <style type="text/css">
        body
        {   
            background:SteelBlue url('BG_BLUE_NEW.jpg') no-repeat center center;
        }
        .login
        {
            width:100px; /*<- important edit*/
            margin: 0 auto; /*<- important edit*/
            margin-top:300px;
            height:300px
        }
    </style>
</head>
<body>
    <div class="container">
    <div class="login">
        <form style="margin-bottom:0px;"><!-- removed padding -->
            <INPUT TYPE="button" style="background-color:SteelBlue;width:100px;height:30px;font-size:150%;margin-bottom:10px" VALUE="Submit" onClick="window.open('http://www.google.com','_blank');"><br>
            <INPUT TYPE="button" style="background-color:SteelBlue;width:100px;height:30px;font-size:150%;margin-bottom:10px" VALUE="Submit" onClick="window.open('http://www.google.com','_blank');"><br>
            <INPUT TYPE="button" style="background-color:SteelBlue;width:100px;height:30px;font-size:150%;margin-bottom:10px" VALUE="Submit" onClick="window.open('http://www.google.com','_blank');"><br>
            <INPUT TYPE="button" style="background-color:SteelBlue;width:100px;height:30px;font-size:150%;margin-bottom:10px" VALUE="Submit" onClick="window.open('http://www.google.com','_blank');"><br>
            <INPUT TYPE="button" style="background-color:SteelBlue;width:100px;height:30px;font-size:150%;margin-bottom:10px" VALUE="Submit" onClick="window.open('http://www.google.com','_blank');"><br>
        </form>
    </div>
    </div>
</body>
</html>

这里发生了什么:

我在 div 上设置了一个指定的 (100px).login来保存也具有 100px 宽度的输入。

然后我应用margin:0 auto了以下内容:将上下边距设置为0,将左右边距设置为“自动”(增长到填充)

之后我删除了<form>元素上的 padding-left

你可以在这里看到它的作用

于 2012-09-07T07:33:12.097 回答