14-vertical-aligin
01 行盒的理解
作用: 将当前行里的所有内容包裹起来
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box .small {
display: inline-block;
width: 200px;
height: 200px;
background-color: orange;
}
.box img {
width: 200px;
}
</style>
</head>
<body>
<div class="box">
xxxxgggx123
<img src="./imgs/diqiu.jpg" alt="">
<span class="small"></span>
每逢春节、中秋节等中华民族传统节日,各族居民便聚在一起,联欢联谊,共庆佳节;每逢开斋节、古尔邦节等少数民族节日,回族居民会带着油香、馓子等特色小吃,请街坊邻里品尝,各族居民其乐融融,像石榴籽一样紧紧抱在一起。
</div>
</body>
</html>

02 行盒里面对齐的方式
浏览器为了美观,默认行盒的对其方式是基线对齐

这也就能解释为什么单独放一张图片的时候,图片下方会有几个像素

这是因为只有图片的时候也是按照基线对齐,为了以后可能有文字,预留了空间
还有一种现象
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
background-color: orange;
}
.box .small {
display: inline-block;
width: 200px;
height: 200px;
background-color: red;
}
.box img {
width: 100px;
}
</style>
</head>
<body>
<div class="box">
123xxggg
<img src="./imgs/diqiu.jpg" alt="">
<span class="small">aaaaa</span>
</div>
</body>
</html>

也是因为基线对齐的原因,因为span里有了文字,所以基线变成了文字的底部,就会发生如上图的现象了
03 案例
3.1 vertical-algin解决问题一
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
/* 浏览器遇到行内和行内块标签当做文字处理, 默认文字是按基线对象 */
input {
height: 50px;
box-sizing: border-box;
vertical-align: middle;
}
</style>
</head>
<body>
<input type="text"><input type="button" value="搜索">
</body>
</html>

3.2 vertical-algin解决问题二
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
img {
vertical-align: middle;
}
</style>
</head>
<body>
<img src="../imgs/1.jpg" alt=""><input type="text">
</body>
</html>

3.3 vertical-algin解决问题三
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.father {
width: 400px;
height: 400px;
background-color: pink;
}
input {
/* vertical-align: middle; */
vertical-align: top;
}
</style>
</head>
<body>
<div class="father">
<input type="text">
</div>
</body>
</html>

3.4 vertical-algin解决问题四
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.father {
width: 400px;
background-color: pink;
}
img {
/* 浏览器把行内和行内块标签当做文字处理,默认基线对齐 */
/* vertical-align: middle; */
display: block;
}
</style>
</head>
<body>
<div class="father">
<img src="../imgs/1.jpg" alt="">
</div>
</body>
</html>

14-vertical-aligin的更多相关文章
- LeetCode Binary Tree Vertical Order Traversal
原题链接在这里:https://leetcode.com/problems/binary-tree-vertical-order-traversal/ 题目: Given a binary tree, ...
- atitit.eclipse 新特性总结3.1--4.3
atitit.eclipse 新特性总结3.1--4.3 Eclipse 3.1 1 Eclipse 3.2 Java开发工具的新特性 2 1. 内容辅助(Ctrl+Space)模板 2 2. 动态地 ...
- 与众不同 windows phone (14) - Media(媒体)之音频播放器, 视频播放器, 与 Windows Phone 的音乐和视频中心集成
原文:与众不同 windows phone (14) - Media(媒体)之音频播放器, 视频播放器, 与 Windows Phone 的音乐和视频中心集成 [索引页][源码下载] 与众不同 win ...
- iOS中UITextField 使用全面解析 分类: ios技术 2015-04-10 14:37 153人阅读 评论(0) 收藏
//初始化textfield并设置位置及大小 UITextField *text = [[UITextField alloc]initWithFrame:CGRectMake(20, 20, 13 ...
- 14 fragment 创建
静态展示 注意 静态的开始进入界面的生命周期和动态的不同 详情:14 fragment注意点 步骤一:创建一个类继承 Fragment 代码类型一: package com.fmy.demo1; im ...
- win7+python3.6+word_cloud 安装出现Microsoft Visual C++ 14.0 is required
说明 环境: 已安装Anaconda3 (64-bit) 4.4.0(Python 3.6.1).其中,代码调试在Spyder 3.1.4中进行,安装包则直接打开Anaconda Prompt调用cm ...
- Devexpress VCL Build v2014 vol 14.2.1 beta发布
已经快到2015 年了. 14.2.1 beta 才出来了. 还好,有一些新东西. 官网地址 VCL Gauge Control Designed to clearly convey informat ...
- Devexpress VCL Build v2013 vol 14.1.3 发布
我修,我修,修修修. New Major Features in 14.1 What's New in VCL Products 14.1 Breaking Changes To learn abou ...
- 【Android】3.14 公交线路查询功能
分类:C#.Android.VS2015.百度地图应用: 创建日期:2016-02-04 一.简介 利用BusLineSearch方法可查询公交线路的详情信息. 二.运行截图 简介:介绍查询公交线路功 ...
- 《DSP using MATLAB》示例 Example 9.14
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
随机推荐
- Windows 窗口样式 什么是 WS_EX_NOREDIRECTIONBITMAP 样式
我觉得我可以加入历史博物馆了,加入微软历史博物馆,本文也是和大家吹历史的博客 简单说这个 WS_EX_NOREDIRECTIONBITMAP 样式是 Win8 提供的,用来做画面图层混合的功能.什么是 ...
- 2018-2-13-win10-uwp-从StorageFile获取文件大小
title author date CreateTime categories win10 uwp 从StorageFile获取文件大小 lindexi 2018-2-13 17:23:3 +0800 ...
- Codeforces Round 940 (Div. 2) and CodeCraft-23 (A-E)
A. Stickogon 题意:给定 \(n\) 根木棒长度,问最多构成几个多边形. 贪心,四边形不会优于三角形. submission B. A BIT of a Construction 题意:构 ...
- Mybatis学习四(分页助手pagehelper)
Mybatis学习过程中有一个很重要的插件分页助手(pagehelper) 能够运用这个插件也非常简单 1.导入jar包 [jsqlparser-2.0.jar包] [点击下载https://gith ...
- 【web安全】修改和配置tomcat版本信息
场景 目前网络安全的越来越受重视,tomcat作为重要的web容器被广泛应用,如何隐藏信息保证.在开放网络世界中,不易被攻击. 操作思路 1.进入Tomcat文件中的lib文件夹,将catalina. ...
- 简说Python之flask初体验
目录 flask初体验 1.安装Flask 2.创建"Hello, World" Flask应用 3.执行结果 flask是python web的轻量框架,简单的几条命令就可以创建 ...
- 8、shell 脚本
1.shell 脚本基础 作用:介于系统内核与用户之间,负责解释命令行 1.1.第一个 shell 脚本 vim first.sh cd /boot/ pwd ls -lh vml*z 赋予可执行权限 ...
- 一些简单的Post方式WebApi接收参数和传递参数的方法及总结
原文地址:https://www.zhaimaojun.top/Note/5475297(我自己的博客网站) 各种Post方式上传参数到服务器,服务器接收各种参数的示例 webapi可以说是很常用了, ...
- linux开发vue项目,不能热更新?
只需要运行下面的命令即可: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo ...
- UnityShader数学基础篇
Mathf Mathf和Math 1.Math是C#中封装好的用于数学计算的工具类,位于System命名空间中. 2.Mathf是Unity中封装好的用于数学计算的工具结构体,位于UnityEngin ...