css 页面没有居中按钮

x0fgdtte  于 2023-03-09  发布在  其他
关注(0)|答案(2)|浏览(139)

我试过了但是没用,
https://jsfiddle.net/lucianopinochet/fzse5962/
如果有人有什么想法,我会非常感谢你。

.container article button{
align-self: center;

}

<div class="container">
                    <article>
                        <h3>Free</h3>
                        <h4>Forever Free Plan</h4>
                        <p>Our generous free forever plan provides you with plenty to get started and get addicted to the tools that will take your work to the next level. No credit card required to get started.</p>
                        <ul>
                            <li>Unlimited pages & links</li>
                            <li>Up to 5 gigabytes of storage</li>
                            <li>Up to 20 databases</li>
                            <li>Share up to 50 pages via URL</li>
                            <li>Up to two guest users per page</li>
                        </ul>
                        <button>Sign Up Now</button>
                    </article>
              
                </div>
sbtkgmzw

sbtkgmzw1#

试试这个:

div{
    width:100%;
    display:flex;
    align-items:center;
    justify-content:center;
}
<div>
   <button>submit</button>
</div>

垂直和水平方向的按钮将以此代码居中。

c9qzyr3d

c9qzyr3d2#

试试这个:
如果希望使用这些属性使按钮居中,请为父元素提供与示例中相同的属性。

.container article button {
        align-self: center;
    }

    article {
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;
    }
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    
</head>

<body>
    <div class="container">
        <article>
            <h3>Free</h3>
            <h4>Forever Free Plan</h4>
            <p>Our generous free forever plan provides you with plenty to get started and get addicted to the tools that
                will take your work to the next level. No credit card required to get started.</p>
            <ul>
                <li>Unlimited pages & links</li>
                <li>Up to 5 gigabytes of storage</li>
                <li>Up to 20 databases</li>
                <li>Share up to 50 pages via URL</li>
                <li>Up to two guest users per page</li>
            </ul>
            <button>Sign Up Now</button>
        </article>

    </div>
</body>

</html>

相关问题