CSS – 调整浏览器窗口大小时修复边框宽度变化
•浏览 1
CSS - Fixed border width change when resizing browser window
我制作了 2 个简单的链接按钮,它们位于 2 个 div 标签内。
这是我试过的 css 和 html 代码:
.lang-box {
position: absolute;
bottom: 60px;
left: 2%;
z-index: 3;
}
.flex-container {
display: flex;
}
.flex-direction-column {
flex-direction: column;
}
.border-gold {
border: 2px solid #ac8b45;
}
.text-gold {
color: #ac8b45;
}
.background-gold {
background-color: #ac8b45;
}
.text-black {
color: #000;
}
.no-background {
background-color: transparent;
}
.lang-a-button {
text-decoration: none;
outline: 0;
display: block;
font-size: 20px;
padding-bottom: 6px;
padding-top: 10px;
padding-left: 6px;
padding-right: 6px;
height: auto;
text-align: center;
}
.lang-a-button:hover {
text-decoration: none;
opacity: .7;
}
EN
IT
* {
box-sizing: border-box;
}
.lang-box {
position: absolute;
top: 60px;
left: 2%;
z-index: 3;
width: 42px;
}
.flex-container{
display: flex;
width: 100%;
}
.flex-direction-column{
flex-direction: column;
}
.border-gold{
border: 2px solid #ac8b45;
}
.text-gold{
color: #ac8b45;
}
.background-gold{
background-color: #ac8b45;
}
.text-black{
color: #000;
}
.no-background{
background-color: transparent;
}
.lang-a-button{
text-decoration: none;
outline: 0;
display: block;
font-size: 20px;
padding-bottom: 6px;
padding-top: 10px;
/* padding-left: 6px;
padding-right: 6px; */
height: auto;
text-align: center;
width: 100%;
flex-grow:0;
flex-shrink:0;
width: 40px;
}
.lang-a-button:hover{
text-decoration: none;
opacity: .7;
}
EN
IT
.lang-box {
position: absolute;
bottom: 60px;
left: 2%;
z-index: 3;
}
.flex-container {
display: flex;
}
.flex-direction-column {
flex-direction: column;
}
.border-gold {
border: 2px solid #ac8b45;
}
.text-gold {
color: #ac8b45;
}
.background-gold {
background-color: #ac8b45;
}
.text-black {
color: #000;
}
.no-background {
background-color: transparent;
}
.lang-a-button {
text-decoration: none;
outline: 0;
display: block;
font-size: 20px;
padding-bottom: 6px;
padding-top: 10px;
padding-left: 6px;
padding-right: 6px;
height: auto;
text-align: center;
}
.lang-a-button:hover {
text-decoration: none;
opacity: .7;
}
EN
IT
* {
box-sizing: border-box;
}
.lang-box {
position: absolute;
top: 60px;
left: 2%;
z-index: 3;
width: 42px;
}
.flex-container{
display: flex;
width: 100%;
}
.flex-direction-column{
flex-direction: column;
}
.border-gold{
border: 2px solid #ac8b45;
}
.text-gold{
color: #ac8b45;
}
.background-gold{
background-color: #ac8b45;
}
.text-black{
color: #000;
}
.no-background{
background-color: transparent;
}
.lang-a-button{
text-decoration: none;
outline: 0;
display: block;
font-size: 20px;
padding-bottom: 6px;
padding-top: 10px;
/* padding-left: 6px;
padding-right: 6px; */
height: auto;
text-align: center;
width: 100%;
flex-grow:0;
flex-shrink:0;
width: 40px;
}
.lang-a-button:hover{
text-decoration: none;
opacity: .7;
}
EN
IT
这是最终的结果:
问题是当我调整浏览器屏幕大小时,.border-gold 的右边框的粗细发生了变化:
我不明白为什么会这样。我尝试使用它,但没有任何改变。
我使用 Google Chrome v69 进行测试。
我需要添加一些东西吗?
尝试添加链接flex-grow:0; flex-shrink:0;和固定宽度,像这样:
.lang-box {
position: absolute;
bottom: 60px;
left: 2%;
z-index: 3;
}
.flex-container {
display: flex;
}
.flex-direction-column {
flex-direction: column;
}
.border-gold {
border: 2px solid #ac8b45;
}
.text-gold {
color: #ac8b45;
}
.background-gold {
background-color: #ac8b45;
}
.text-black {
color: #000;
}
.no-background {
background-color: transparent;
}
.lang-a-button {
text-decoration: none;
outline: 0;
display: block;
font-size: 20px;
padding-bottom: 6px;
padding-top: 10px;
padding-left: 6px;
padding-right: 6px;
height: auto;
text-align: center;
}
.lang-a-button:hover {
text-decoration: none;
opacity: .7;
}
EN
IT
* {
box-sizing: border-box;
}
.lang-box {
position: absolute;
top: 60px;
left: 2%;
z-index: 3;
width: 42px;
}
.flex-container{
display: flex;
width: 100%;
}
.flex-direction-column{
flex-direction: column;
}
.border-gold{
border: 2px solid #ac8b45;
}
.text-gold{
color: #ac8b45;
}
.background-gold{
background-color: #ac8b45;
}
.text-black{
color: #000;
}
.no-background{
background-color: transparent;
}
.lang-a-button{
text-decoration: none;
outline: 0;
display: block;
font-size: 20px;
padding-bottom: 6px;
padding-top: 10px;
/* padding-left: 6px;
padding-right: 6px; */
height: auto;
text-align: center;
width: 100%;
flex-grow:0;
flex-shrink:0;
width: 40px;
}
.lang-a-button:hover{
text-decoration: none;
opacity: .7;
}
EN
IT
.lang-box {
position: absolute;
bottom: 60px;
left: 2%;
z-index: 3;
}
.flex-container {
display: flex;
}
.flex-direction-column {
flex-direction: column;
}
.border-gold {
border: 2px solid #ac8b45;
}
.text-gold {
color: #ac8b45;
}
.background-gold {
background-color: #ac8b45;
}
.text-black {
color: #000;
}
.no-background {
background-color: transparent;
}
.lang-a-button {
text-decoration: none;
outline: 0;
display: block;
font-size: 20px;
padding-bottom: 6px;
padding-top: 10px;
padding-left: 6px;
padding-right: 6px;
height: auto;
text-align: center;
}
.lang-a-button:hover {
text-decoration: none;
opacity: .7;
}
EN
IT
* {
box-sizing: border-box;
}
.lang-box {
position: absolute;
top: 60px;
left: 2%;
z-index: 3;
width: 42px;
}
.flex-container{
display: flex;
width: 100%;
}
.flex-direction-column{
flex-direction: column;
}
.border-gold{
border: 2px solid #ac8b45;
}
.text-gold{
color: #ac8b45;
}
.background-gold{
background-color: #ac8b45;
}
.text-black{
color: #000;
}
.no-background{
background-color: transparent;
}
.lang-a-button{
text-decoration: none;
outline: 0;
display: block;
font-size: 20px;
padding-bottom: 6px;
padding-top: 10px;
/* padding-left: 6px;
padding-right: 6px; */
height: auto;
text-align: center;
width: 100%;
flex-grow:0;
flex-shrink:0;
width: 40px;
}
.lang-a-button:hover{
text-decoration: none;
opacity: .7;
}
EN
IT
我没有确切的答案,但我认为这是因为 flex 的特殊性