【问题标题】:Border Radius Not Working in a CSS Class边框半径在 CSS 类中不起作用
【发布时间】:2017-10-21 11:06:58
【问题描述】:

我正在尝试为按钮添加边框半径,但是当我在下面的 CSS 代码中使用 border-radius: 5px; 时,没有任何反应。其他一切都有效,只是一个关键字不起作用。我读过的所有内容都表明它应该如何工作,但它不在下面的代码中。我不知道我是否只是在下面遗漏了什么?

HTML:

 <button class="button" style="vertical-align:middle"><span>Play</span></button>

CSS:

html {
 height: 100%;
}

body {
 background-image: url("/images/wallpaper.jpg"); 
 background-size: 100% 100%;
 background-repeat: no-repeat;
 height: 100%;
 overflow: hidden; 
}

.heading {
 font-family: Sedgwick Ave Display;
 font-size: 70px;
 color: #cccc00;
}
.subH {
 font-family: Cinzel;
 font-size: 8px;
 position: fixed;
 bottom: 0.05px;
 left: 1190px;
 color: white;
}

.boxhead a {
 color: #FFFFFF;
 text-decoration: none;
}

.button {
  border-radius: 55px;
  position: fixed;
  top: 140px;
  left: 75px;
  font-size: 70px;
  font-family: Sedgwick Ave Display;
  display: inline-block;
  background-color: #cccc00;
  border: none; 
  color: #FFFFFF;
  text-align: center;
  font-size: 28px;
  padding: 20px;
  width: 200px;
  transition: all 0.5s;
  cursor: pointer;
  margin: 5px;
 }

.button span {
 cursor: pointer;
 display: inline-block;
 position: relative;
 transition: 0.5s;
}

.button span:after {
 content: '\00bb';
 position: absolute;
 opacity: 0;
 top: 0;
 right: -20px;
 transition: 0.5s;
}

.button:hover span {
  padding-right: 25px;
}

.button:hover span:after {
 opacity: 1;
 right: 0;
}

【问题讨论】:

  • 尝试添加重要的。喜欢border-radius: 5px; !important。如果这可行,则您的原始 css 将在某处被覆盖。您可能需要打开控制台并找到冲突的 css。

标签: html css


【解决方案1】:

.button { 边框半径:5px; // 这是行不通的

这就是为什么它不起作用:

border-radius: 4px;

...您在同一规则中还有几行,从而覆盖以前的值。

【讨论】:

  • 即使没有第一个border-radius也不行:5px;
  • 没有第一个是什么意思?你说 是行不通的。如果不是这样,那么请阅读如何创建minimal reproducible example,并编辑您的问题,以便我们实际重现您的问题。
  • 你说有两个“border-radius”关键字是正确的,但是即使我从代码中删除了其中一个,按钮上仍然没有边框半径。跨度>
  • 我将此代码复制到一个新的 ASP.NET MVC 项目中,并且该按钮具有圆角边框,因此您的代码可以正常工作...必须是您提供的代码之外的其他内容。
  • 那么您可能有其他 CSS 规则干扰,或者代码 sn-ps 中不明显的其他错误,如单独显示的那样。所以,请创建一个适当的问题示例。
猜你喜欢
  • 2015-09-12
  • 1970-01-01
  • 2016-06-01
  • 2012-06-02
  • 2013-12-22
  • 2017-07-08
  • 1970-01-01
  • 1970-01-01
  • 2013-05-13
相关资源
最近更新 更多