图片居中的flex实现
文本居中
text-align:center;
如果是图片放在div中,就没办法了。用flex可以很简单实现。
display: flex;
justify-content: center; /* 图片居中 */
下面是案例:

html
<!-- 优势 -->
<div class="strength">
<div class="strength-title">
创新优势
</div>
<div class="strength-container">
<div class="strength-item">
<div class="strength-item-icon">
<img src="/Index/Index/image/innovate/shenduhezuo.png" alt="">
</div>
<div class="strength-item-title">
产学研深度合作
</div>
<div class="strength-item-content">
力邀世界一流大学科学家加盟,带领研究团队参与企业级创新方案规划。
</div>
</div>
<div class="strength-item">
<div class="strength-item-icon">
<img src="/Index/Index/image/innovate/xianjinlinian.png" alt="">
</div>
<div class="strength-item-title">
先进的实施理念
</div>
<div class="strength-item-content">
以产品思维取代项目思维, 将产品化的理念贯彻到创新的每一个环节,每一个人。
</div>
</div>
<div class="strength-item">
<div class="strength-item-icon">
<img src="/Index/Index/image/innovate/genji.png" alt="">
</div>
<div class="strength-item-title">
牢靠的根基
</div>
<div class="strength-item-content">
先进的云计算技术平台,支撑起以宝尊多年品牌电商运营经验培育的电商云生态平台。
</div>
</div>
<div class="strength-item">
<div class="strength-item-icon">
<img src="/Index/Index/image/innovate/biaozhun.png" alt="">
</div>
<div class="strength-item-title">
标准化能力
</div>
<div class="strength-item-content">
通过标准化的数据,打造标准化的产品,使宝尊具备提供标准化科技服务的能力。
</div>
</div>
</div>
</div>
css
.strength {
height: 518px;
background-color: #F6F8FC;
overflow: hidden;
.strength-title {
margin-top:100px;
font-size: 30px;
font-weight: bold;
text-align: center;
}
.strength-container {
width: 925px;
margin:0 auto;
margin-top:63px;
display: flex;
justify-content: space-between;
.strength-item {
width: 208px;
height: 208px;
//border: 1px solid red;
.strength-item-icon {
display: flex;
justify-content: center; /* 图片居中 */
height: 56px;
}
.strength-item-title {
margin-top: 30px;
font-size: 20px;
font-weight: bold;
text-align: center;
}
.strength-item-content {
margin-top: 23px;
font-size: 16px;
color: #222222;
text-align: center;
}
}
}
}
图片居中的flex实现的更多相关文章
- css文字居中、图片居中、div居中解决方案
一.文字居中 若文字只有一行 <!--html代码--> <div class="box"> <p class="text"> ...
- !!!css如何让img图片居中?css的display属性实现图片居中(代码实例)
在我们开发前端页面的时候,为了让页面效果美观,会让图片呈现居中效果.那么css怎么让img图片居中显示呢?本篇文章给大家带来css如何让img图片居中?css的display属性实现图片居中(代码实例 ...
- css图片居中(水平居中和垂直居中)
css图片居中(水平居中和垂直居中) css图片居中分css图片水平居中和垂直居中两种情况,有时候还需要图片同时水平垂直居中,下面分几种居中情况分别介绍. css图片水平居中 利用margin: 0 ...
- HTML/CSS:图片居中(水平居中和垂直居中)
css图片居中(水平居中和垂直居中) css图片居中分css图片水平居中和垂直居中两种情况,有时候还需要图片同时水平垂直居中, 下面分几种居中情况分别介绍: css图片水平居中 1.利用margin: ...
- css图片居中,通过纯css实现图片居中的多种实现方法
在网页布局中,图文排版是我们常用的,那么经常会遇到如何让图片居中显示呢,这篇文章将总结常用css实现图片居中的方法总结: html结构: <div class="demo" ...
- line-height,vertical-align及图片居中对齐问题根源解析
关于图片居中对齐的问题,进入前端行业虽然有一段时间了,以为自己懂了,可是实际上还是一知半解,找了一些博客来看了一下,但是感觉讲的有点碎,看完还是一知半解. 查阅了一下<css权威指南>,结 ...
- Html、Css-----当有文字和图片的时候,需要文字和图片居中,怎么实现?不想文字换行怎么设置
1 当有文字和图片的时候,需要文字和图片居中,怎么实现? <a href=#" target="aa" style="white-space:nowrap ...
- [转]div 让文字或图片居中
本文转自:http://qsfwy.iteye.com/blog/250206 在div 中让 文字或图片居中,请参考以下代码1: - - - - - - - - - - - - - - - - - ...
- 用CSS让网页背景图片居中的方法
网页背景居中的方法有很多种的.这里介绍一些用CSS让背景图片居中的方法. 让背景图片居中的第一个方法是用像素设定,很多都用这种,但是也是最麻烦的: <div style="width: ...
随机推荐
- 【Oracle】SQL/92 执行多个表的连接
内连接 外连接 自连接 交叉连接 1.内连接 表名 INNER JOIN 表名 ON 条件 等价于: FROM 表名, 表名 WHERE 条件 SELECT p.name, pt.name, pt.p ...
- 输入DStream之基础数据源以及基于HDFS的实时wordcount程序
输入DStream之基础数据源以及基于HDFS的实时wordcount程序 一.Java方式 二.Scala方式 基于HDFS文件的实时计算,其实就是,监控一个HDFS目录,只要其中有新文件出现,就实 ...
- PTA 乙 1002
1002 写出这个数 题目描述 读入一个正整数 n,计算其各位数字之和,用汉语拼音写出和的每一位数字. 输入格式 每个测试输入包含 1 个测试用例,即给出自然数 n 的值.这里保证 n 小于 10^1 ...
- 使用 noexcept 我们需要知道什么?
noexcept 关键字 noexcept 是什么? noexcept 是自 C++11 引入的新特性,指定函数是否可能会引发异常,以下是 noexcept 的标准语法: noexcept-expre ...
- Codeforces Round #682 (Div. 2)【ABCD】
比赛链接:https://codeforces.com/contest/1438 A. Specific Tastes of Andre 题意 构造一个任意连续子数组元素之和为子数组长度倍数的数组. ...
- Codeforces Round #647 (Div. 2) B. Johnny and His Hobbies(枚举)
题目链接:https://codeforces.com/contest/1362/problem/B 题意 有一个大小及元素值均不超过 $1024$ 的正整数集合,求最小正整数 $k$,使得集合中的每 ...
- codeforces #345 (Div. 1) D. Zip-line (线段树+最长上升子序列)
Vasya has decided to build a zip-line on trees of a nearby forest. He wants the line to be as long a ...
- codeforces629C Famil Door and Brackets (dp)
As Famil Door's birthday is coming, some of his friends (like Gabi) decided to buy a present for him ...
- FZU1894 志愿者选拔
Problem Description 世博会马上就要开幕了,福州大学组织了一次志愿者选拔活动.参加志愿者选拔的同学们排队接受面试官们的面试.参加面试的同学们按照先来先面试并且先结束的原则接受面试官们 ...
- Codeforces Round #649 (Div. 2) C、Ehab and Prefix MEXs D、Ehab's Last Corollary 找环和点染色
题目链接:C.Ehab and Prefix MEXs 题意; 有长度为n的数组a(下标从1开始),要求构造一个相同长度的数组b,使得b1,b2,....bi集合中没有出现过的最小的数是ai. mex ...