紅色邊框僅供參考。我試過overflow: hidden了,但沒有用。我正在嘗試與紅色邊框具有相同的邊框半徑。有什么我做錯了嗎?謝謝你。
*,*::before, *::after {
margin: 0;
padding: 0;
box-sizing: border-box;
--violet: #8F00FF;
}
.rating {
border: 1px solid red;
border-radius: 8px;
width: 30px;
margin-left: 100px;
margin-top: 100px;
background-color: #f0f0f0;
display: flex;
flex-direction: column;
box-shadow: -5px 0px 8px rgba(172, 169, 169, 0.1);
}
button {
border: none;
border-radius: 8px;
align-items: center;
color: var(--violet);
font-weight: bold;
cursor: pointer;
-webkit-border-radius:10px;
overflow: hidden;
}
.rating span {
display: flex;
justify-content: center;
color: var(--violet);
font-weight: bold;
}
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Interface</title>
<!-- CSS Link -->
<link rel="stylesheet" href="style.css">
<!-- Boxicons -->
<script src="https://unpkg.com/[email protected]/dist/boxicons.js"></script>
<!-- Bootstrap -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- JS Link -->
<script src="script.js" defer></script>
</head>
<body>
<!-- <div >
</div> -->
<div class="rating">
<button> </button>
<span>12</span>
<button>-</button>
</div>
</body>
</html>
uj5u.com熱心網友回復:
您應該添加overflow: hidden哪個.rating有助于用邊框半徑完全覆寫內部元素
*,*::before, *::after {
margin: 0;
padding: 0;
box-sizing: border-box;
--violet: #8F00FF;
}
.rating {
border: 1px solid red;
border-radius: 8px;
width: 30px;
margin-left: 100px;
margin-top: 100px;
background-color: #f0f0f0;
display: flex;
flex-direction: column;
box-shadow: -5px 0px 8px rgba(172, 169, 169, 0.1);
overflow: hidden; /*The change is here*/
}
button {
border: none;
border-radius: 8px;
align-items: center;
color: var(--violet);
font-weight: bold;
cursor: pointer;
-webkit-border-radius:10px;
overflow: hidden;
}
.rating span {
display: flex;
justify-content: center;
color: var(--violet);
font-weight: bold;
}
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Interface</title>
<!-- CSS Link -->
<link rel="stylesheet" href="style.css">
<!-- Boxicons -->
<script src="https://unpkg.com/[email protected]/dist/boxicons.js"></script>
<!-- Bootstrap -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- JS Link -->
<script src="script.js" defer></script>
</head>
<body>
<!-- <div >
</div> -->
<div class="rating">
<button> </button>
<span>12</span>
<button>-</button>
</div>
</body>
</html>
uj5u.com熱心網友回復:
這種行為是由于 bootstrap 導致的,因為在 bootstrap<button>中已經給出了標簽,border-radius:0因此您不能在直接標簽上更改它,而是可以創建button一個類并將其提供給<button>標簽。
*,*::before, *::after {
margin: 0;
padding: 0;
box-sizing: border-box;
--violet: #8F00FF;
}
.rating {
border: 1px solid red;
border-radius: 8px;
width: 30px;
margin-left: 100px;
margin-top: 100px;
background-color: #f0f0f0;
display: flex;
flex-direction: column;
box-shadow: -5px 0px 8px rgba(172, 169, 169, 0.1);
}
.button {
border: none;
-webkit-border-radius: 8px;
border-radius: 8px;
align-items: center;
color: var(--violet);
font-weight: bold;
cursor: pointer;
overflow: hidden;
}
.rating span {
display: flex;
justify-content: center;
color: var(--violet);
font-weight: bold;
}
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Interface</title>
<!-- CSS Link -->
<link rel="stylesheet" href="style.css">
<!-- Boxicons -->
<script src="https://unpkg.com/[email protected]/dist/boxicons.js"></script>
<!-- Bootstrap -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- JS Link -->
<script src="script.js" defer></script>
</head>
<body>
<!-- <div >
</div> -->
<div class="rating">
<button class="button"> </button>
<span>12</span>
<button class="button">-</button>
</div>
</body>
</html>
uj5u.com熱心網友回復:
您可以添加overflow: hidden;類.rating。
.rating {
...
overflow: hidden;
}
或者您只需要為of添加!important規則。通過這種方式,您不必添加for 。border-radiusbuttonoverflow.rating
button {
...
border-radius: 8px !important;
}
*,*::before, *::after {
margin: 0;
padding: 0;
box-sizing: border-box;
--violet: #8F00FF;
}
.rating {
border: 1px solid red;
border-radius: 8px;
width: 30px;
margin-left: 100px;
margin-top: 100px;
background-color: #f0f0f0;
display: flex;
flex-direction: column;
box-shadow: -5px 0px 8px rgba(172, 169, 169, 0.1);
overflow: hidden;
}
button {
border: none;
border-radius: 8px !important;
align-items: center;
color: var(--violet);
font-weight: bold;
cursor: pointer;
}
.rating span {
display: flex;
justify-content: center;
color: var(--violet);
font-weight: bold;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Interface</title>
<!-- CSS Link -->
<link rel="stylesheet" href="style.css">
<!-- Boxicons -->
<script src="https://unpkg.com/[email protected]/dist/boxicons.js"></script>
<!-- Bootstrap -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- JS Link -->
<script src="script.js" defer></script>
</head>
<body>
<!-- <div >
</div> -->
<div class="rating">
<button> </button>
<span>12</span>
<button>-</button>
</div>
</body>
</html>
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/530738.html
標籤:htmlcss
上一篇:Chrome擴展-如何在主擴展彈出視窗(default_popup)和頁面腳本(web_accessible_resources)之間進行互動
下一篇:如何將JS功能添加到側邊選單?
