css - 部分页面未正确呈现 css 类

标签 css angularjs

我创建了 .css 类来创建不同颜色的圆圈。如果我在一个文件中使用 css 类,它会按预期工作。但是,当我尝试在 Angular 部分页面中使用它时,它无法正确呈现?

正确:Correct 不正确:Incorrect

这是红色圆圈的CSS类

  .red-circle {
  margin: 40px auto 0;
  width: 30px;
  height: 30px;
  border-radius: 100%;
  border: 1px solid #c92c09;
}.red-circle:before, .red-circle:after {
  content: '';
  width: 15px;
  height: 30px;
}.red-circle:before {
  float: left;
  border-top-left-radius: 15px;
  border-bottom-left-radius: 15px;
  background: #c92c09;
}.red-circle:after {
  float: right;
  border-top-right-radius: 15px;
  border-bottom-right-radius: 15px;
  background: #c92c09;
}

下面是它在正确的 html 页面中的使用方式

 <link rel="stylesheet" href="../css/circles.css" type="text/css" />
 <body>      
      <div class="red-circle"><div>
    </body>

这是显示不正确的 html

<div class="container" ng-controller="FieldCtrl">
    <link rel="stylesheet" href="../css/circles.css" type="text/css" />
    <div class="red-circle"> </div>
</div>

最佳答案

只需添加 positiontop 并删除 floats,而是使用 rightleft

CSS

.red-circle {
  margin: 40px auto 0;
  width: 30px;
  height: 30px;
  border-radius: 100%;
  border: 1px solid #c92c09;
  position: relative;
}

.red-circle:before,
.red-circle:after {
  top: 0;
  position: absolute;
  content: '';
  width: 15px;
  height: 30px;
}

.red-circle:before {
  left: 0;
  border-top-left-radius: 15px;
  border-bottom-left-radius: 15px;
  background: #c92c09;
}

.red-circle:after {
  right: 0;
  border-top-right-radius: 15px;
  border-bottom-right-radius: 15px;
  background: #c92c09;
}

.container {
  display: inline-block;
}

DEMO HERE

关于css - 部分页面未正确呈现 css 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37282022/

相关文章:

html - CSS 网格流不同大小的 block

javascript - ng-repeat td 中的输入字段不触发功能

javascript - AngularJS - 使用 ngMockE2E $httpBackend 如何延迟特定响应?

html - 100% 宽度不适用于 div。 WordPress的

css - jquery datepicker 创建不必要的空格

html - 页脚显示在页眉导航下

html - css 下拉菜单不会在悬停时保持打开状态

javascript - 从下拉列表中选择时如何获取日期对象

AngularJS 拦截器没有将 JWT Bearer 放入 node.js 应用程序的每个请求中

javascript - 如何在 angular($window).bind() 中访问它?