简体   繁体   English

使用背景图像的框架

[英]frame using a Background-image

I put a frame in my images.我在我的图像中放置了一个框架。

I created a CSS for the background-image is the image of the frame, but he must have an x padding for the frame is seen.我为背景图像创建了一个 CSS,它是框架的图像,但他必须有一个 x 填充才能看到框架。

img.frame
{
    background-image:url('http://bit.ly/k8g8zz');
    background-repeat:no-repeat;
    background-position: center;
    background-size: 100%;
    padding:23px 14px 60px;
}

I can not use a div inside of another because I need this image is a link with a title, and the W3C can not be div tags within a.我不能在另一个div里面使用一个,因为我需要这个图片是一个带有标题的链接,而W3C不能是div标签内的一个。

If possible, change the jsFiddle and send me the link如果可能,请更改 jsFiddle 并将链接发送给我

See the complete code here .请参阅此处的完整代码

As you can see in jsFiddle, the frame is the wrong size.. she needs to grow along with the image and have a padding.正如您在 jsFiddle 中看到的那样,框架的大小不正确。她需要与图像一起增长并具有填充。

Thank you all for your help.谢谢大家的帮助。

You almost have it!你几乎拥有它! Just set both dimensions of background-size ;只需设置background-size的两个尺寸;

background-size: 100% 100%;

http://jsfiddle.net/vLBXH/ http://jsfiddle.net/vLBXH/

You can't set a width and height for a background-image in CSS, AFAIK.您不能在 CSS,AFAIK 中为背景图像设置宽度和高度。 If you use a fixed-width image (PNG) you also should have images of the matching size.如果您使用固定宽度的图像 (PNG),您还应该拥有匹配大小的图像。 Another approach might be to style the frame with CSS only or have an framing-tag around the linked image, which you then may style, like:另一种方法可能是仅使用 CSS 对框架进行样式设置,或者在链接图像周围添加一个框架标签,然后您可以对其进行样式设置,例如:

<div class="img_frame">
    <a href="#nohref"><imgr src="#noimg" /></a>
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM