老师麻烦您帮忙看一下代码正确性和规范性

老师麻烦您帮忙看一下代码正确性和规范性

具体遇到的问题

老师麻烦您帮忙看一下代码正确性和规范性

报错信息的截图

相关课程内容截图

尝试过的解决思路和结果

按钮这里我设置了text-align: center; 没有起到效果,请问老师这里应该怎么写呢

粘贴全部相关代码,切记添加代码注释(请勿截图)

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>banner4_6</title>
    <link rel="stylesheet" href="css/banner4_6.css">
</head>

<body>

    <div class="banner">
        <img class="banner-img" src="images/banner3.jpg" alt="">
        <div class="imgShade"></div>
        <form>
            <input type="text" placeholder="your Name">
            <input type="tel" placeholder="your Phone">
            <input type="email" placeholder="your Email">
            <textarea placeholder="Write Your Comment Here"></textarea>
            <button type="submit">SEND MESSAGE</button>
        </form>
    </div>

</body>

</html>
* {
    padding: 0;
    margin: 0;
}

.banner {
    width: 100%;
    height: 600px;
    position: relative;
}

.banner .banner-img {
    position: absolute;
    width: 100%;
    height: 600px;
}

.banner .imgShade {
    position: absolute;
    width: 100%;
    height: 600px;
    background: rgba(0, 0, 0, .5);
}

.banner form {
    width: 504px;
    background: none;
    position: absolute;
    top: 100px;
    left: 50%;
    margin-left: -252px;
}

.banner form input {
    width: 504px;
    height: 40px;
    margin-bottom: 20px;
    border: 1px solid #808080;
    background: none;
    color: white;
}

.banner form textarea {
    width: 504px;
    height: 110px;
    margin-bottom: 20px;
    background: none;
    border: 1px solid #808080;
}

.banner form button {
    width: 200px;
    height: 40px;
    background: none;
    border: 1px solid #808080;
    color: #808080;
    /* text-align: center; */
    left: 50%;
    margin-left: 150px;
}

正在回答

登陆购买课程后可参与讨论,去登陆

1回答

同学你好,代码写的很规范哦。不过代码实现的效果中有一个小问题,表单整体没有被父元素包裹住,如下:

http://img1.sycdn.imooc.com//climg/5fa8b8ca09c3604c06560513.jpg

这是因为表单里的元素的宽度是504px,但是里面的表单元素都有border边框值,所以按照盒模型计算(504+border左右边框)=506px,如下图:

http://img1.sycdn.imooc.com//climg/5fa8b982094f119c14900611.jpg

参考下图修改:

http://img1.sycdn.imooc.com//climg/5fa8b93d09a073ea04690270.jpg

祝学习愉快!

  • 日拱一卒_ 提问者 #1
    还有个问题请教您,按钮我设置了text-align:center; 但是没有效果,麻烦您再帮我看一下
    2020-11-09 11:44:23
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师