0

I have a DIV where I need to place an arrow from a sprite image.

The arrow in the sprite image is 276x276px but I need to display it with half size.

div {
  background-attachment: scroll;
  background-clip: border-box;
  background-image: url("https://www.designworkplan.com/content/3-read/8-free-vector-arrows/designworkplan_vector_arrow_collection-01.png");
  background-origin: padding-box;
  background-position: -55px -44px;
  background-size: auto;
  box-sizing: border-box;
  display: block;
  font-size: 11px;
  height: 276px;
  line-height: 15px;
  position: absolute;
  left: 20px;
  top: 20px;
  width: 276px;
}
<div></div>

How to do this?

isherwood
  • 58,414
  • 16
  • 114
  • 157
Miguel Moura
  • 36,732
  • 85
  • 259
  • 481

2 Answers2

1

As I understand you you want to have the arrow smaller but still inside a container.

That would work like this:

div.background {
  background-attachment: scroll;
  background-clip: border-box;
  background-image: url("https://www.designworkplan.com/content/3-read/8-free-vector-arrows/designworkplan_vector_arrow_collection-01.png");
  background-origin: padding-box;
  background-position: -55px -44px;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  transform: scale(0.5);
  transform-origin: top left;
}

.wrapper {
  box-sizing: border-box;
  display: block;
  font-size: 11px;
  height: 276px;
  line-height: 15px;
  position: absolute;
  left: 20px;
  top: 20px;
  width: 276px;
  background: red;
}
<div class="wrapper">
  <div class="background">
  </div>
</div>

If you just want the arrow smaller (without any wrappers) then just remove it.

div {
  background-attachment: scroll;
  background-clip: border-box;
  background-image: url("https://www.designworkplan.com/content/3-read/8-free-vector-arrows/designworkplan_vector_arrow_collection-01.png");
  background-origin: padding-box;
  background-position: -55px -44px;
  height: 276px;
  position: absolute;
  left: 20px;
  top: 20px;
  width: 276px;
  transform: scale(0.5);
  transform-origin: top left;
  line-height: 15px;
  font-size: 11px;
}
<div></div>
Aaron3219
  • 2,168
  • 4
  • 11
  • 28
1
add this  transform: scale(0.5);

div {
  background-attachment: scroll;
  background-clip: border-box;
  background-image: url("https://www.designworkplan.com/content/3-read/8-free-vector-arrows/designworkplan_vector_arrow_collection-01.png");
  background-origin: padding-box;
  background-position: -55px -44px;
  background-size: auto;
  box-sizing: border-box;
  display: block;
  font-size: 11px;
  height: 276px;
  line-height: 15px;
  position: absolute;
  transform: scale(0.5);
  left: 20px;
  top: 20px;
  width: 276px;
}
<div></div>
Umar Abdullah
  • 1,282
  • 1
  • 19
  • 37