侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

css – 背景图像宽度

2023-03-28 星期二 / 0 评论 / 0 点赞 / 77 阅读 / 1044 字

这是我的 HTML: <div id="user-avatar"><img src="/imgs/frame.png" alt=""/></div> 用户头像类如下: #user-

... . . 这是我的 HTML:

<div id="user-avatar"><img src="/imgs/frame.png" alt=""/></div>

用户头像类如下:

#user-avatar {     width: 100px;     height: 100px;     margin: auto;     position: relative;     background: url(images/avatars/128.jpg) 50% 50% no-repeat;}

帧:

#user-avatar img {      position: absolute;      top: 50%;      left: 50%;      width: 122px;      height: 127px;      margin-top: -62px;      margin-left: -63px; }

原始用户头像背景图像尺寸是23×25,但我希望它被调整为100x100px,问题是,无论我在宽度:xxx属性中设置它都不起作用.框架后面的头像每次都有原始尺寸.

.

解决方法

. 您无法将图像集调整为容器的背景.调整图像大小的唯一方法是使用img标记并使用width和height css属性调整其大小.

看看here可能会有所帮助.

. . .. ...

广告 广告

评论区