18910140161

HTML-一个按钮只是不想居中-堆栈溢出

顺晟科技

2022-10-19 11:44:16

71

我最近出于无聊开始做一些html和css,试图做一个类似众筹的网站,但无论我做什么,我的捐赠按钮都不想居中。我所做的其他按钮,包括捐赠按钮下面的按钮,似乎都是居中的。

在我看来是这样的:https://prnt.sc/1os63hf

如果可以请帮忙这里是我的代码


顺晟科技:

尝试此:

将div元素作为父元素添加到节并使用flex

.par2 { /* free space*/
    margin-top: 9%;
}

.txt1 { 
    font-family: 'Roberto';
    color: white;
    text-align: center;
}

section .button { /* button*/
    font-family: 'Roboto';
    font-size: 24px;
    color: #151D21;
    background: #ff7a7a;
    display: inline-flex;
    padding: 6px;
    margin-top: 30px;
    margin-right: 5%;
    margin-left: 45%;
    margin-bottom: 6%;
    border: none;
    border-radius: 5px;
    text-align: center;
}

section .button:hover {
    background: white;
    -webkit-transform:  scale(1.1);
    -ms-transform: scale(1.1);
    transform: scale(1.1);
}

我建议您将

元素包装在
中。 我在
元素中都使用了flex,并将它们居中; 我从代码中删除了margin-left和margin-right。 此外,我将文本颜色更改为黑色。

检查是否有不明白的地方。

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航