我怎样才能在我的边境内得到这个箭头?

时间:2018-05-10 09:33:56

标签: css

我有货币转换器, 这是它的样子: https://gyazo.com/661e6713051bb5ddb288a92f66b24c92 所以,我在课后插入了箭头:然而,在某些主题之后(我们正在为shopify做一个项目)我必须给箭头一个正确的,以使它看起来不错。任何想法我如何在边境内获得箭头? css看起来像

.vitals-nice-select {
    -webkit-tap-highlight-color: transparent;
    background-color: #fff;
    color: #333;
    box-sizing: border-box;
    clear: both;
    cursor: pointer;
    display: block;
    float: left;
    font-family: inherit;
    font-size: 14px;
    font-weight: normal;
    height: 42px;
    line-height: 40px;
    outline: none;
    padding-left: 18px;
    padding-right: 23px;
    position: relative;
    text-align: left !important; 
    webkit-transition: all 0.2s ease-in-out;
    transition: all 0.2s ease-in-out;
    -webkit-user-select: none; 
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    white-space: nowrap;
    width: auto;
    border-radius: 5px;
    border: solid 1px #e8e8e8;
}

.vitals-nice-select:hover {
    border-color: #dbdbdb;
}

和箭头

.vitals-nice-select:after {
    border-bottom: 2px solid #999;
    border-right: 2px solid #999;
    content: \'\';
    display: block;
    height: 5px;
    margin-top: -4px;
    pointer-events: none;
    position: absolute;
    right: 12px;
    top: 50%;
    -webkit-transform-origin: 66% 66%;
    -ms-transform-origin: 66% 66%;
    transform-origin: 66% 66%;
    -webkit-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    transform: rotate(45deg);
    -webkit-transition: all 0.15s ease-in-out;
    transition: all 0.15s ease-in-out;
    width: 5px;
}

2 个答案:

答案 0 :(得分:0)

请参阅此处的小提琴:https://jsfiddle.net/9o1L1Lg4/

添加以下属性:

.vitals-nice-select {
  position: relative;
}

.vitals-nice-select:after {
  position: absolute;
  right: 0;
  /* If you want to center it vertically add the following properties */
  top: 50%;
  transform: translatey(-50%);
}

答案 1 :(得分:0)

这是你想要的吗?

.vitals-nice-select {
  -webkit-tap-highlight-color: transparent;
  background-color: #fff;
  color: #333;
  box-sizing: border-box;
  clear: both;
  cursor: pointer;
  display: block;
  float: left;
  font-family: inherit;
  font-size: 14px;
  font-weight: normal;
  height: 42px;
  line-height: 42px;
  outline: none;
  padding-left: 18px;
  padding-right: 30px;
  position: relative;
  text-align: left !important;
  webkit-transition: all 0.2s ease-in-out;
  transition: all 0.2s ease-in-out;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  white-space: nowrap;
  width: auto;
  border-radius: 5px;
  border: solid 1px #e8e8e8;
}

.vitals-nice-select:hover {
  border-color: #dbdbdb;
}

.vitals-nice-select:after {
  border-bottom: 2px solid #999;
  border-right: 2px solid #999;
  content: '';
  display: block;
  height: 5px;
  pointer-events: none;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: rotate(45deg) translateX(-50%);
  transition: all 0.15s ease-in-out;
  width: 5px;
}
<div class="vitals-nice-select">TextTextText</div>