Как контролировать размер стрелки CSS - PullRequest
0 голосов
/ 27 сентября 2018

Я создал стрелку в CSS.Все работает как надо, кроме размера стрелки.Я не уверен, как мне сделать его меньше.

Как мне сделать стрелку меньше?

#blue {
  width: 100%;
  height: 100vh;
  background: blue;
}
#box2 {
	position: absolute;
	top: 25%;
	right: 25%;
	z-index: 1;
}
#box2Text {
	color: #FFF;
	font-family: 'Muli', sans-serif;
	font-size: 2rem;
	font-weight: 300;
	line-height: 1.4em;
	padding: 80px;
	border: 6px solid #FFF;
	border-radius: 2px;
	display: block;
	text-align: center;
}
#arrow {
	margin-top: 10px;
	border: solid #FFF;
    border-width: 0 3px 3px 0;
    display: block;
    padding: 3px;
	transform: rotate(45deg);
    -webkit-transform: rotate(45deg);
}
<section id="blue">
  <div id="box2">
    <span id="box2Text">View Services</span>
    <div id="arrow"></div>
  </div>
</section>

Желаемый выход:

enter image description here

Ответы [ 3 ]

0 голосов
/ 27 сентября 2018

Как это?

#blue {
  width: 100%;
  height: 100vh;
  background: blue;
}
#box2 {
	position: absolute;
	top: 25%;
	right: 25%;
	z-index: 1;
}
#box2Text {
	color: #FFF;
	font-family: 'Muli', sans-serif;
	font-size: 2rem;
	font-weight: 300;
	line-height: 1.4em;
	padding: 80px;
	border: 6px solid #FFF;
	border-radius: 2px;
	display: block;
	text-align: center;
}
#arrow {
    margin-right:15px;
    margin-bottom:5px;
	border: solid #FFF;
    border-width: 0 3px 3px 0;
    display: inline-block;
    padding: 3px;
	transform: rotate(-45deg);
    -webkit-transform: rotate(-45deg);
    width: 5px;
    height: 5px;
}
<section id="blue">
  <div id="box2">
    <span id="box2Text"><div id="arrow"></div><span>View Services</span></span>
  </div>
</section>
0 голосов
/ 27 сентября 2018

Используйте стрелку как псевдоэлемент текстового элемента div, и вы можете легко разместить его и настроить его размер:

#blue {
  width: 100%;
  height: 100vh;
  background: blue;
}

#box2 {
  position: absolute;
  top: 25%;
  right: 25%;
  z-index: 1;
}

#box2Text {
  color: #FFF;
  font-family: 'Muli', sans-serif;
  font-size: 2rem;
  font-weight: 300;
  line-height: 1.4em;
  padding: 80px;
  border: 6px solid #FFF;
  border-radius: 2px;
  display: block;
  text-align: center;
  position:relative;
}
#box2Text:after {
  content:"";
  left:calc(50% - 5px);
  margin-top:40px;
  position:absolute;
  border: solid #FFF;
  border-width: 0 3px 3px 0;
  width:10px;
  height:10px;
  transform: rotate(45deg);
}
<section id="blue">
  <div id="box2">
    <span id="box2Text">View Services</span>
  </div>
</section>
0 голосов
/ 27 сентября 2018

Вам просто нужно указать атрибуты CSS width и height для #arrow.после этого вам может понадобиться отрегулировать положение стрелки в соответствии с вашими потребностями

#blue {
  width: 100%;
  height: 100vh;
  background: blue;
}
#box2 {
	position: absolute;
	top: 25%;
	right: 25%;
	z-index: 1;
}
#box2Text {
	color: #FFF;
	font-family: 'Muli', sans-serif;
	font-size: 2rem;
	font-weight: 300;
	line-height: 1.4em;
	padding: 80px;
	border: 6px solid #FFF;
	border-radius: 2px;
	display: block;
	text-align: center;
}
#arrow {
	margin-top: 10px;
	border: solid #FFF;
    border-width: 0 3px 3px 0;
    display: block;
    padding: 3px;
	transform: rotate(45deg);
    -webkit-transform: rotate(45deg);
    width: 5px;
    height: 5px;
}
<section id="blue">
  <div id="box2">
    <span id="box2Text">View Services</span>
    <div id="arrow"></div>
  </div>
</section>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...