简体   繁体   English

如何在具有不同属性(CSS)的圆形中拟合颜色?

[英]How to fit color in circle with different properties (CSS)?

I have a CSS circle property like this: 我有这样的CSS圈属性:

.btn-circle {
  color: #fff;
  background: #5191d1;
  width: 60px;
  height: 60px;
  padding: 18px 0;
  font-size: 24px;
  border-radius: 50%;
  display: block;
  margin: 0 auto;
  margin-bottom: 6px;
  line-height: normal;
  transition: all .3s ease-in-out 0s;
}

And I'm trying to create different CSS properties to choose the color for the button. 我正在尝试创建不同的CSS属性以选择按钮的颜色。 For example: 例如:

.bg-blue {
  background-color: #5191d1 !important;
  border-color: #269abc;
}

// also bg-red, bg-yellow, etc...

The problem is when using "btn-circle bg-blue", my page ends like this: 问题是当使用“ btn-circle bg-blue”时,我的页面如下所示结束:

http://prntscr.com/a9nmkz

Instead of this: 代替这个:

在此处输入图片说明

Is the problem due to a parent property (col-md-4) ? 问题是由于父属性(col-md-4)引起的吗? What can I do? 我能做什么?

Thank you. 谢谢。

I used your CSS and its working. 我使用了您的CSS及其工作原理。

 <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" /> <style> .btn-circle { color: #fff; background: #5191d1; width: 60px; height: 60px; padding: 18px 0; font-size: 24px; border-radius: 50%; display: block; margin: 0 auto; margin-bottom: 6px; line-height: normal; transition: all .3s ease-in-out 0s; } .bg-blue { background-color: #5191d1 !important; border-color: #269abc; } </style> <div class="container"> <div class="row"> <div class="col-md-4"> <a class="btn btn-circle bg-blue"><i class="glyphicon glyphicon-calendar"></i> </a> </div> </div> </div> 

It would be clearer to reach to the root cause of the problem if you would have provided the html code as well. 如果您还提供了html代码,则更清楚地找出问题的根本原因。

Assuming that the a div element with class "btn-circle bg-blue" is inside a parent div. 假设类“ btn-circle bg-blue”的div元素位于父div内。 Make sure that the backgound-color of parent div is not same as that of the round div (child). 确保父div的背景色与圆div(子div)的背景色不同。

For example (Correct Code): 例如(正确代码):

 .btn-circle { color: #fff; background: #5191d1; width: 60px; height: 60px; padding: 0px 0; font-size: 24px; border-radius: 50%; display: block; margin: 0 auto; margin-bottom: 6px; line-height: normal; transition: all .3s ease-in-out 0s; } .bg-blue { background-color: #5191d1 !important; border-color: #269abc; } .bg-orange { background-color: #FFD185; } 
 <div class="bg-orange"> <div class="btn-circle bg-blue"> </div> </div> 

Whereas Incorrect Code, would show up like this: 而不正确的代码将显示如下:

 .btn-circle { color: #fff; background: #5191d1; width: 60px; height: 60px; padding: 0px 0; font-size: 24px; border-radius: 50%; display: block; margin: 0 auto; margin-bottom: 6px; line-height: normal; transition: all .3s ease-in-out 0s; } .bg-blue { background-color: #5191d1 !important; border-color: #269abc; } .bg-orange { background-color: #FFD185; } 
 <div class="bg-blue"> <div class="btn-circle bg-blue"> </div> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM