我的问题是按钮的中小型版本。我希望它们的大小比仅具有btn
类的主按钮小。
请随时编辑代码,并给我一个答案,为什么类btn--med
和btn--small
对按钮的外观没有影响。
这是代码:
.btn {
&:link,
&:visited {
text-transform: uppercase;
text-decoration: none;
background-color: #000;
color: #777;
padding: 27px 40px;
display: inline-block;
border-radius: 100px;
transition: all .2s;
min-width: 30rem;
min-height: 8rem;
text-align: center;
margin-right: 5rem;
}
&--small {
max-width: 10rem;
background-color: blue;
}
&--med {
max-height: 5rem;
}
}
<div class="div-1">
<a href="#" class="btn">Programista</a>
</div>
<div class="div-2">
<a href="#" class="btn btn--med">SCSS</a>
</div>
<div class="div-3">
<a href="#" class="btn btn--small">SCSS</a>
</div>
答案 0 :(得分:0)
这是我的解决方法
.btn {
text-transform: uppercase;
text-decoration: none;
background-color: #000;
color: #777;
padding: 27px 40px;
display: inline-block;
border-radius: 100px;
transition: all 0.2s;
min-width: 30rem;
min-height: 8rem;
text-align: center;
margin-right: 5rem;
&:link,
&:visited {
}
&.btn--small {
min-width: 10rem;/*Change this value according to your needs*/
min-height: 3rem;/*Change this value according to your needs*/
background-color: blue;
}
&.btn--med {
min-height: 5rem;/*Change this value according to your needs*/
min-width: 15rem;/*Change this value according to your needs*/
}
}
为中小按钮替换min-width
而不是max-width
答案 1 :(得分:0)
由于在min-width
上使用了min-height
和btn
属性。更改它们:
.btn {
&:link,
&:visited {
text-transform: uppercase;
text-decoration: none;
background-color: #000;
color: #777;
padding: 27px 40px;
display: inline-block;
border-radius: 100px;
transition: all .2s;
text-align: center;
margin-right: 5rem;
}
&--small {
max-width: 10rem;
background-color: blue;
}
&--med {
max-height: 5rem;
}
}
如果标定的值小于在min-width和min-height中声明的值,则min-height和min-width会覆盖宽度和高度。
答案 2 :(得分:0)
You should modify same properties for both btn--small and btn--med button class.
in your code for "btn--small" you are modifying its "max-width" property.
while for "btn--med" you are modifying "max-height" property.
Modify same properties for both classes.
for example
&--small {
max-width: 10rem;
background-color: blue;
max-height: 5rem;
}
&--med {
max-height: 5rem;
max-width: 5rem;
}
答案 3 :(得分:0)
类似于其他答案,您需要修改相同的属性以及相同的伪类。由于您是主按钮,只需触摸:link
和:visited
,您的--sm
和--med
也需要用:link
和:visited
换行>