gpt4 book ai didi

html - css 按钮大小不一样

转载 作者:行者123 更新时间:2023-11-28 02:29:12 24 4
gpt4 key购买 nike

我在这个网站上看了很多关于这个问题的教程,但没有任何效果。此外,代码主要来 self 正在修改的模板。我怎样才能修复它,使按钮“旋律”和“安妮”的大小相同并且不会相互重叠?这是我的代码:

/* Links */

a,
a:focus,
a:hover {
color: #fff;
}

.custom {
width: 78px !important;
}


/* Melody */

.btn-Melody {
color: #333;
text-shadow: none;
background-color: #a9cafc;
border: 0.05rem solid #a9cafc;
}

.btn-Melody:hover {
color: #333;
background-color: #72a8f9;
border: 0.05rem solid #72a8f9;
}

.btn-Melody:focus {
color: #333;
text-shadow: none;
border: 0.05rem solid #72a8f9;
}


/* Anne */

.btn-Anne {
color: #333;
text-shadow: none;
/* Prevent inheritance from `body` */
background-color: #a9fcab;
border: 0.05rem solid #a9fcab;
}

.btn-Anne:hover {
color: #333;
background-color: #5bff5f;
border: 0.05rem solid #5bff5f;
}

.btn-Anne:focus {
color: #333;
text-shadow: none;
/* Prevent inheritance from `body` */
background-color: #fff;
border: 0.05rem solid #fff;
}


/*
* Base structure
*/

html,
body {
height: 100%;
background-color: #333;
/*background-image: url("Anne.png")*/
}

body {
color: #ffffff;
text-align: center;
text-shadow: 0 0.05rem 0.1rem rgba(0, 0, 0, 0.5);
}


/* Extra markup and styles for table-esque vertical and horizontal centering */

.site-wrapper {
display: table;
width: 100%;
height: 100vh;
/* For at least Firefox */
min-height: 100%;
box-shadow: inset 0 0 5rem rgba(0, 0, 0, 0.5);
}

.site-wrapper-inner {
display: table-cell;
vertical-align: top;
}

.cover-container {
margin-right: auto;
margin-left: auto;
}


/* Padding for spacing */

.inner {
padding: 2rem;
}


/*
* Header
*/

.masthead {
margin-bottom: 2rem;
}

.masthead-brand {
margin-bottom: 0;
}

.nav-masthead .nav-link {
padding: 0.25rem 0;
font-weight: 700;
color: rgba(255, 255, 255, 0.5);
background-color: transparent;
border-bottom: 0.25rem solid transparent;
}

.nav-masthead .nav-link:hover,
.nav-masthead .nav-link:focus {
border-bottom-color: rgba(255, 255, 255, 0.25);
}

.nav-masthead .nav-link+.nav-link {
margin-left: 1rem;
}

.nav-masthead .active {
color: #fff;
border-bottom-color: #fff;
}

@media (min-width: 48em) {
.masthead-brand {
float: left;
}
.nav-masthead {
float: right;
}
}


/*
* Cover
*/

.cover {
padding: 0 1.5rem;
}

.cover .btn-lg {
padding: 0.75rem 1.25rem;
font-weight: 700;
}


/*
* Footer
*/

.mastfoot {
color: #000000;
}


/*
* Affix and center
*/

@media (min-width: 40em) {
/* Pull out the header and footer */
.masthead {
position: fixed;
top: 0;
}
.mastfoot {
position: fixed;
bottom: 0;
}
/* Start the vertical centering */
.site-wrapper-inner {
vertical-align: middle;
}
/* Handle the widths */
.masthead,
.mastfoot,
.cover-container {
width: 100%;
/* Must be percentage or pixels for horizontal alignment */
}
}

@media (min-width: 62em) {
.masthead,
.mastfoot,
.cover-container {
width: 42rem;
}
<link rel="stylesheet" href="template.css">

<div class="site-wrapper">

<div class="site-wrapper-inner">

<div class="cover-container">

<header class="masthead clearfix">
<div class="inner">
<h3 class="masthead-brand">Cover</h3>
<nav class="nav nav-masthead">
<a class="nav-link active" href="#">Home</a>
<a class="nav-link" href="#">Features</a>
<a class="nav-link" href="#">Contact</a>
</nav>
</div>
</header>

<body>

</body>
<main role="main" class="inner cover">

<h1 class="cover-heading">Cover your page.</h1>
<p class="lead">Cover is a one-page template for building simple and beautiful home pages. Download, edit the text, and add your own fullscreen background photo to make it your own.</p>
<p class="lead">
<a href="#" class="btn btn-lg btn-Melody custom">Melody</a>
<p>
<a href="#" class="btn btn-lg btn-Anne custom">Anne</a>
</p>

<footer class="mastfoot">
<div class="inner">
<p>Website by
<a href="#">ChloeM</a>.</p>
</div>
</footer>

</div>

</div>

</div>

我试图制作一张表格,试图为它们添加一个 !important 以固定宽度,但它似乎没有用。

最佳答案

发生元素重叠是因为第二个按钮被包装到一个带有 margin 的段落中。将按钮从段落中取出,就可以了。您还可以在段落中使用填充而不是边距,这样元素就不会重叠。

  /* Links */

a,
a:focus,
a:hover {
color: #fff;
}

.custom {
width: 78px !important;
}


/* Melody */

.btn-Melody {
color: #333;
text-shadow: none;
background-color: #a9cafc;
border: 0.05rem solid #a9cafc;
}

.btn-Melody:hover {
color: #333;
background-color: #72a8f9;
border: 0.05rem solid #72a8f9;
}

.btn-Melody:focus {
color: #333;
text-shadow: none;
border: 0.05rem solid #72a8f9;
}


/* Anne */

.btn-Anne {
color: #333;
text-shadow: none;
/* Prevent inheritance from `body` */
background-color: #a9fcab;
border: 0.05rem solid #a9fcab;
}

.btn-Anne:hover {
color: #333;
background-color: #5bff5f;
border: 0.05rem solid #5bff5f;
}

.btn-Anne:focus {
color: #333;
text-shadow: none;
/* Prevent inheritance from `body` */
background-color: #fff;
border: 0.05rem solid #fff;
}


/*
* Base structure
*/

html,
body {
height: 100%;
background-color: #333;
/*background-image: url("Anne.png")*/
}

body {
color: #ffffff;
text-align: center;
text-shadow: 0 0.05rem 0.1rem rgba(0, 0, 0, 0.5);
}


/* Extra markup and styles for table-esque vertical and horizontal centering */

.site-wrapper {
display: table;
width: 100%;
height: 100vh;
/* For at least Firefox */
min-height: 100%;
box-shadow: inset 0 0 5rem rgba(0, 0, 0, 0.5);
}

.site-wrapper-inner {
display: table-cell;
vertical-align: top;
}

.cover-container {
margin-right: auto;
margin-left: auto;
}


/* Padding for spacing */

.inner {
padding: 2rem;
}


/*
* Header
*/

.masthead {
margin-bottom: 2rem;
}

.masthead-brand {
margin-bottom: 0;
}

.nav-masthead .nav-link {
padding: 0.25rem 0;
font-weight: 700;
color: rgba(255, 255, 255, 0.5);
background-color: transparent;
border-bottom: 0.25rem solid transparent;
}

.nav-masthead .nav-link:hover,
.nav-masthead .nav-link:focus {
border-bottom-color: rgba(255, 255, 255, 0.25);
}

.nav-masthead .nav-link+.nav-link {
margin-left: 1rem;
}

.nav-masthead .active {
color: #fff;
border-bottom-color: #fff;
}

@media (min-width: 48em) {
.masthead-brand {
float: left;
}
.nav-masthead {
float: right;
}
}


/*
* Cover
*/

.cover {
padding: 0 1.5rem;
}

.cover .btn-lg {
padding: 0.75rem 1.25rem;
font-weight: 700;
}


/*
* Footer
*/

.mastfoot {
color: #000000;
}


/*
* Affix and center
*/

@media (min-width: 40em) {
/* Pull out the header and footer */
.masthead {
position: fixed;
top: 0;
}
.mastfoot {
position: fixed;
bottom: 0;
}
/* Start the vertical centering */
.site-wrapper-inner {
vertical-align: middle;
}
/* Handle the widths */
.masthead,
.mastfoot,
.cover-container {
width: 100%;
/* Must be percentage or pixels for horizontal alignment */
}
}

@media (min-width: 62em) {
.masthead,
.mastfoot,
.cover-container {
width: 42rem;
}
<link rel="stylesheet" href="template.css">

<div class="site-wrapper">

<div class="site-wrapper-inner">

<div class="cover-container">

<header class="masthead clearfix">
<div class="inner">
<h3 class="masthead-brand">Cover</h3>
<nav class="nav nav-masthead">
<a class="nav-link active" href="#">Home</a>
<a class="nav-link" href="#">Features</a>
<a class="nav-link" href="#">Contact</a>
</nav>
</div>
</header>

<body>

</body>
<main role="main" class="inner cover">

<h1 class="cover-heading">Cover your page.</h1>
<p class="lead">Cover is a one-page template for building simple and beautiful home pages. Download, edit the text, and add your own fullscreen background photo to make it your own.</p>
<p class="lead">
<a href="#" class="btn btn-lg btn-Melody custom">Melody</a>

<a href="#" class="btn btn-lg btn-Anne custom">Anne</a>


<footer class="mastfoot">
<div class="inner">
<p>Website by
<a href="#">ChloeM</a>.</p>
</div>
</footer>

</div>

</div>

</div>

关于html - css 按钮大小不一样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52025719/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com