html - 如何对齐背景图像中心
问题描述
我正在尝试添加背景图像中心,但我无法做到我已经尝试了所有方法但无法做到。这是我尝试过的代码
<a href="#" style="background-position:center center;">
<img src="https://firebasestorage.googleapis.com/v0/b/growthfilepractice.appspot.com/o/ownerCampaign.jpg?alt=media&token=846535ef-b1c7-4063-aace-6e0843f9d001" style="width:800px;height:800px">
</a>
<a href="#">
<img src="https://firebasestorage.googleapis.com/v0/b/growthfilepractice.appspot.com/o/ownerCampaign.jpg?alt=media&token=846535ef-b1c7-4063-aace-6e0843f9d001" style="width: 800px;height: 800px;background-repeat: no-repeat;
background-attachment: fixed;
background-position: center; ">
</a>
解决方案
你需要添加一些样式
a {
width: 800px;
height: 800px;
background-repeat: no-repeat;
background-image: url('https://firebasestorage.googleapis.com/v0/b/growthfilepractice.appspot.com/o/ownerCampaign.jpg?alt=media&token=846535ef-b1c7-4063-aace-6e0843f9d001');
background-position: center;
}
推荐阅读
- c# - 通过交易混合发布者确认和非确认
- javascript - 扩展 WebSocket 类
- php - Laravel 5.5 作为缓存驱动程序的 Memcached 问题
- r - ggplot2中分组条形名称的格式样式
- vba - VBA:从下拉菜单中选择以重新加载页面并抓取数据
- azure - 一个 Azure Function App,多个区域:一个或多个 Azure Application Insights 实例?
- hyperledger-fabric - 超级账本结构 Orderer 创世区块生成
- ios - 如何从 Webview 中的 javascript 函数中获取价值?
- user-interface - 将 Primefaces 主题转换为 Material Design UI
- reactjs - 使用 React-Dnd-touch-Backend 示例