html - CSS 文本对齐。我不知道我的代码有什么问题

标签 html css text alignment

我刚开始写代码。但是我在我的CSS中遇到了一个错误。错误是我希望按钮居中对齐,但它不会对齐。

这可能很明显,但我不知道哪里出了问题。

请帮帮我。如果你愿意帮忙,我会很高兴。 这是我的代码:

<!DOCTYPE HTML>
<html>
<head>
    <h1>Help</h1>
</head>    
<body>
    <br>
    <a class="button" onClick='window.location="view-source:" + window.location.href' target="_blank">View Source</a>
</body>

<style>
    h1 {
        color: black;
        text-align: center;
    }

    a[target=_blank] {
        text-align: center;
    }

    .button {
        text-align: center;
        padding: 0 5px 5px 5px;
        background-color: #dcdcdc;
        border: 1px solid #666;
        color: #000;
        text-decoration: none;
        font-family: "arial";
        font-size: 100%;
    }
</style>
</html>

我在网上找不到任何东西

最佳答案

如果你说你在网上没有找到任何东西,你一定根本没有尝试过。

阅读 margin 属性以及其余的 HTML 和 CSS 教程。

http://www.w3schools.com/css/css_margin.asp

关于html - CSS 文本对齐。我不知道我的代码有什么问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33684646/

相关文章:

c++ - 提取文本 OpenCV

html - 悬停下拉

html - 如何设置 ionic 选择项的默认值?

jquery - 为什么不能在 jquery .animate() 中使用 $(this)?

html - 使 div 的高度为视口(viewport)高度的 100% 或页面的整个高度

JavaScript 和 CSS - 我这样做对吗?

javascript - Jquery Fadein/FadeOut 同时进行

html - 主 slider 调整大小以适应行容器

html - 水平滚动条问题

javascript - 使用 jQuery 从字面上将文本分解到随机位置