如何将插入的图片在HTML页面指定相对位置

<div style="text-align: right;font-size: 26px;background:url('../o2_core/o2/xDesktop/jlrc_bgimg/meng_banner.png') no-repeat center;width:100%; height:770px;">
<ul style="top:270px;position:relative;margin:0 auto;width:1010px;height:55px;list-style:none;">
<li>
<a style='list-style: none;margin: 0;text-decoration: none;font-size: 20px;color: #FFF;font-family: "黑体";font-weight: bold;float: left;padding: 0px 28px 0px 28px;display: block;height: 55px;line-height: 55px;' href="/" title="首页">首页</a>
</li>
<li>
<a style='list-style: none;margin: 0;text-decoration: none;font-size: 20px;color: #FFF;font-family: "黑体";font-weight: bold;float: left;padding: 0px 28px 0px 28px;display: block;height: 55px;line-height: 55px;' href="/" title="公司新闻">公司新闻</a>
</li>
<li>
<a style='list-style: none;margin: 0;text-decoration: none;font-size: 20px;color: #FFF;font-family: "黑体";font-weight: bold;float: left;padding: 0px 28px 0px 28px;display: block;height: 55px;line-height: 55px;' href="/" title="文件发布">文件发布</a>
</li>
</ul>
<div style="top:295px;position:relative;margin:0 auto;width:1010px;height:300px;list-style:none;">
<div style="position: relative;float: left;">
<img id="img" src="../o2_core/o2/xDesktop/jlrc_bgimg/p1.jpg" width="600">
</div>

<div style="background:#fff5eb;" class="wang-left-top3-rig navBlock">
</div>
</div>
</div>

截图
在这里插入图片描述
在这里插入图片描述
用大div套小div,大div定宽,剧中,小div设置为相对位置靠左漂浮即可。position: relative;float: left;

  • 10
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在HTML插入图片指定位置,可以使用div元素和CSS样式来实现。首先,通过HTML的img标签插入图片,并设置一个唯一的id或class来标识该图片元素。然后,在CSS样式表中,使用该id或class选择器来为该图片元素指定位置。可以使用position属性来设置元素的定位方式,例如,将其设置为relative相对定位,然后使用top、right、bottom和left属性来调整图片位置。例如,假设你想要在一个大的div元素中插入图片,并将其放置在靠左边的位置,可以按照以下步骤进行操作: 1. 在HTML中,将img标签插入到一个div元素中,并为该元素设置一个唯一的id或class: ```html <div id="imageContainer"> <img src="image.jpg" alt="图片描述"> </div> ``` 2. 在CSS样式表中,为该id或class选择器指定样式,并设置其定位方式为relative相对定位,并将其漂浮到左边: ```css #imageContainer { position: relative; float: left; } ``` 通过以上步骤,你就可以在HTML插入图片,并将其指定到特定的位置。<span class="em">1</span><span class="em">2</span> #### 引用[.reference_title] - *1* [如何将插入图片HTML页面指定相对位置](https://blog.csdn.net/qq_27361945/article/details/107844904)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [北京邮电大学 BUPT 数据库课程 实验一 查询代码 数据库语言MySQL](https://download.csdn.net/download/weixin_51120885/88245030)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值