How can I remove the padding around the background image?


Vincent

How can I remove the "padding" around the background image?

Here is a demo : https://jsbin.com/dobucizaqi/edit?html,css,output

.foo {
   background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%23f39c12' d='M3,19V5A2,2 0 0,1 5,3H19A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5A2,2 0 0,1 3,19M17,12L12,7V10H8V14H12V17L17,12Z'/%3E%3C/svg%3E");
   background-repeat: no-repeat;
   background-size: 8em 8em;
   height: 8em;
   width: 8em;
}
.bar {
  background-color: red;
  align-items: center;
  display: flex;
}
<div class="bar">
  <div class="foo"></div>
  <p>Lorem ipsum</p>
</div>

I have tried to remove the margins and padding without success.

I want the two left borders to align and remove the "padding" around the horizontal and vertical.

thanks.

v.

Accompanying Afif

Just adjust the viewBox of the SVG:

.foo {
   background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='3 3 18 18'%3E%3Cpath fill='%23f39c12' d='M3,19V5A2,2 0 0,1 5,3H19A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5A2,2 0 0,1 3,19M17,12L12,7V10H8V14H12V17L17,12Z'/%3E%3C/svg%3E");
   background-repeat: no-repeat;
   background-size: 8em 8em;
   height: 8em;
   width: 8em;
}
.bar {
  background-color: red;
  align-items: center;
  display: flex;
}
<div class="bar">
  <div class="foo"></div>
  <p>Lorem ipsum</p>
</div>

Related


How can I remove this top space in the background image?

username i used a simple html code to set a background image to my web page but it still shows a free space at the top of the page, i tried this code to make the background image come to life, lift it up, can you confirm me, this is The correct way or is there

How can I remove the padding around the background image?

Vincent How can I remove the "padding" around the background image? Here is a demo : https://jsbin.com/dobucizaqi/edit?html,css,output .foo { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox=

How can I remove the border around the toolbar?

Axl In my app I'm using the toolbar and it seems I want to get rid of the border around it: Then I create it like this: <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:bac

How can I remove the input field around the image button?

select volume I made a clickable image button that triggers a popup upload window, but I can't seem to remove the button's input field from around the image. If you have any ideas on how to fix this, please point me in the right direction. Thanks! Here is the

How can I remove the space around the SVG?

awkward sight I know there are many posts related to this, I have checked all of them but couldn't find a proper solution for my problem, that's why I am posting this question. I have an SVG like this: As you can see, this SVG has no spaces on the top left and

How can I remove this top space in the background image?

username i used a simple html code to set a background image to my web page but it still shows a free space at the top of the page, i tried this code to make the background image come to life, lift it up, can you confirm me, this is The correct way or is there

How can I increase the padding around the plot?

it I have a horizontal bar chart with too tight padding: data <- data.frame(month = factor(c("Nov", "Dec", "Jan", "Feb")), count = c(1489, 788, 823, 1002)) g <- (ggplot2::ggplot(data, ggplot2::aes(x=month, y=count)) + ggplot2::geom_

How can I remove this top space in the background image?

username i used a simple html code to set a background image to my web page but it still shows a free space at the top of the page, i tried this code to bring the background image to life, lift it up, can you confirm me, this is The correct way or is there any

How can I remove the border around the image?

username How can I remove the border around the square? Exterior: my HTML: <input id="black" type="image" src="html5-canvas-drawing-app/images/color-swatch-brown.png" onClick="changeColorBlack()"> my css: #black{ border:none; outline:none; background:none; pa

How can I remove this top space in the background image?

username i used a simple html code to set a background image to my web page but it still shows a free space at the top of the page, i tried this code to bring the background image to life, lift it up, can you confirm me, this is The correct way or is there any

Remove extra padding around background image from button

ranchos Here is the code used to generate the button Button delBtn = new Button(activity); LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); delBtn.setLayoutParams(params); delBtn.setCompoundDrawablesWithIntrinsicBo

How can I remove the input field around the image button?

select volume I made a clickable image button that triggers a popup upload window, but I can't seem to remove the button's input field from around the image. If you have any ideas on how to fix this, please point me in the right direction. Thanks! Here is the

How can I remove this top space in the background image?

username i used a simple html code to set a background image to my web page but it still shows a free space at the top of the page, i tried this code to make the background image come to life, lift it up, can you confirm me, this is The correct way or is there

How can I remove this top space in the background image?

username i used a simple html code to set a background image to my web page but it still shows a free space at the top of the page, i tried this code to make the background image come to life, lift it up, can you confirm me, this is The correct way or is there

How can I remove the padding around the background image?

Vincent How can I remove the "padding" around the background image? Here is a demo : https://jsbin.com/dobucizaqi/edit?html,css,output .foo { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox=

How can I increase the padding around the plot?

it I have a horizontal bar chart with too tight padding: data <- data.frame(month = factor(c("Nov", "Dec", "Jan", "Feb")), count = c(1489, 788, 823, 1002)) g <- (ggplot2::ggplot(data, ggplot2::aes(x=month, y=count)) + ggplot2::geom_

How can I increase the padding around the plot?

it I have a horizontal bar chart with too tight padding: data <- data.frame(month = factor(c("Nov", "Dec", "Jan", "Feb")), count = c(1489, 788, 823, 1002)) g <- (ggplot2::ggplot(data, ggplot2::aes(x=month, y=count)) + ggplot2::geom_

Remove extra padding around background image from button

ranchos Here is the code used to generate the button Button delBtn = new Button(activity); LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); delBtn.setLayoutParams(params); delBtn.setCompoundDrawablesWithIntrinsicBo