将箭头向下添加到半径按钮

时间:2015-09-29 08:23:22

标签: javascript jquery html css

我有一个半径按钮,想要在此按钮内添加一个向下箭头图标。

这是我到目前为止所做的:

.test {
  border: 2px solid #ffffff;
  background: #444444;
  width: 25px;
  height: 25px;
  border-radius: 6px;
  text-align: center;
  color:#ffffff;
}
.down {
  position : absolute;
  top      : 6px;
  left     : 10px;
  width    : 0;
  height   : 0;
  z-index  : 100;
  border-left   : 10px solid transparent;
  border-right  : 10px solid transparent;
  border-top : 10px solid white;
}
<div class="test  ">
  <div class="down"> </div>
</div>

如果代码段不起作用,here就是小提琴。

为什么按钮内没有箭头?

这就是我想要的:

Image of desired result

3 个答案:

答案 0 :(得分:3)

.test {
    border: 2px solid #ffffff;
    background: #444444;
    width: 25px;
    height: 25px;
    border-radius: 6px;
    text-align: center;
    position: relative;
}

.down {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    width: 0;
    height: 0;
    z-index: 100;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid white;
    margin: auto;
}
<div class="test ">
 <div class="down"> </div>
</div>

答案 1 :(得分:1)

如果您想知道如何显示箭头,可以使用Boot Strap,在HTML代码的基础上添加引用并使用它的组件:

.test {
    border: 2px solid #ffffff;
    background: #444444;
    width: 25px;
    height: 25px;
    border-radius: 6px;
  text-align: center;
    
}

.down-arrow{
  margin-top:7px;
  
  }
<!DOCTYPE html>
<html>
<head>
  
  <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  
    <title></title>
	<meta charset="utf-8" />
</head>
<body>
<div class="test">
  <span class="glyphicon glyphicon-arrow-down down-arrow" aria-hidden="true" style="color:white;"></span>
  </div>
</body>
</html>

还有另一种简单的方法,你可以使用字体真棒组件,在谷歌上查看

答案 2 :(得分:0)

尝试将postion:relative; maring:0px auto;用于down

相关问题