HTML form 垂直水平居中

HTML中body代码:

<body>

  <div class="divForm">
   <form action="" method="post">
    <p>
    欢迎登陆网站主页
    </p>
    <p>
    用户名:<input type="text" name="username"/>
    </p>
    <p>
    密 &nbsp;&nbsp;码:<input type="password" name="password"/>
    </p>
    <input type="submit" value="提交"/>
   </form>
    </div>
  </body>

 

然后,head中的style代码:

<style type="text/css">
    .divForm{
        position: absolute;/*绝对定位*/
        width: 500px;
        height: 200px;

        text-align: center;/*(让div中的内容居中)*/
        top: 50%;
        left: 50%;
        margin-top: -300px;
        margin-left: -300px;
    }
</style>

各位朋友可亲测,完了后,将border: 1px solid red;去掉即可


原文:https://blog.csdn.net/nick520920/article/details/51774751 

第二种:

head中style

<style type="text/css">
    body{
        text-align: center;
       margin:0 auto;

    }
    .divForm{
        display: inline-block;
    }
</style>

body中代码:

<body>
<h1 style="text-align: center">图书借阅系统---后台管理</h1>
<form action="javascript:search()" method="post"  id="search">
    图书名称:<input type="text" name="bookName" id="bookName" value=""/> 
    <input type="submit" value="查询"/>
    <input type="hidden" name="pageindex" id="pageindex" value="1"/>
    <button οnclick="add()" style="width: 50px;height: 25px">新增</button>
</form>
    <table id="tt" class="divForm" border="1">
        <tr style="background-color:grey">
            <td>图书编号</td>
            <td>图书分类</td>
            <td>图书名称</td>
            <td>作者</td>
            <td>出版社</td>
            <td>入库时间</td>
            <td>是否借阅</td>
            <td>操作</td>
        </tr>
    </table>

</body>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值