[英]Remove White space around image - CSS
I'm trying to get image from odoo database to show the image into div background, but my image has white space around it, so i need to remove this white space to apply div background image, 我正在尝试从odoo数据库中获取图像以将图像显示到div背景中,但是我的图像周围有空白,因此我需要删除此空白以应用div背景图像,
Mycode : 我的代码:
<div t-attf-style="text-align:center;background:url('/web/image/event.event.ticket/#{doc.event_ticket_id.id}/image_medium') no-repeat;
font-size:#{doc.event_ticket_id.font_size}px;width:50%;height:900px;float:left;background-size:500px 900px;display:table;">
<span style="vertical-align:middle;text-align:center;display:table-cell;" t-esc="doc.name"></span>
</div>
How to remove white space around images using CSS ? 如何使用CSS删除图像周围的空白?
Maybe try one of these code's: 也许尝试以下代码之一:
img{vertical-align:bottom}
or 要么
img { vertical-align: top; }
or 要么
html, body {
margin: 0;
padding: 0;
}
Hope it helped. 希望能有所帮助。
You can try something like this 您可以尝试这样的事情
.main{ text-align:center; background:url('https://i.stack.imgur.com/hQPzy.png') no-repeat; font-size:12px; width:50%; height:900px; float:left; background-size:500px 900px; display:table; background-position:-50px -35px; }
<div class="main"> <span style="vertical-align:middle;text-align:center;display:table-cell;"> Content</span> </div>
But you have to know size of white space of images. 但是您必须知道图像空白区域的大小。 Then you can (-) the position.
然后,您可以(-)位置。
I have tried something. 我试过了 Please check it this works fine for you.
请检查是否适合您。 Here I have tried to set background position and background size.
在这里,我尝试设置背景位置和背景尺寸。 Rest everything can vary like div's width and height.
休息一切都可以像div的宽度和高度一样变化。
.back{ background: url('https://i.stack.imgur.com/hQPzy.png'); height: 200px; width: 200px; background-size: 130% 150%; border: 1px solid black; background-position: 42% 15%; }
<div class="back"></div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.