CSS代码片段
定位:
将元素居中
将元素水平居中
将元素垂直居中
样式:
文字毛玻璃效果 -------------------------------------------代码------------------------------------------------------ 将元素居中:
1.使用绝对定位实现1
{
width: 50px;
height: 50px; /*设置元素宽高*/
position: absolute; /*修改为绝对定位*/
top: 50%;
left: 50%; /*设置与上、左的距离*/
margin-top: -25px;
margin-left: -25px; /*外边距分别为宽高的一半*/
}
2.使用绝对定位实现2
{
position: absolute;
left: 50%;
top: 50%;
transform: tranplate(-50%, -50%);
}
3.使用父元素文本流水平居中,单元格显示垂直居中
#parent{
text-align: center; /*设置子元素水平居中*/
display: table-cell; /*设置为表格单元格显示*/
vertical-align: middle; /*设置垂直对齐方式为居中*/
}
#child{
display: inline-block;
} 将元素水平居中
1.使用外边距自动实现(相对父元素居中)
{
margin: 0 auto;
}
2.将父元素文本流水平居中,配合子元素变成行内快(child里的文字也会水平居中,可以在.child添加text-align:left;还原)
#parent{
text-align: center;
}
#child{
display: inline-block;
} 将元素垂直居中
1.将父元素设置为表格单元格显示,使内容垂直居中(子元素垂直居中)
#parent{
display: table-cell; /*设置为表格单元格显示*/
vertical-align:middle; /*设置垂直对齐方式为居中*/
} 文字毛玻璃效果
1.将文字设置成黑色透明,然后加上投影
{
color:rgba(0,0,0,0);
text-shadow: 0 0 10px black;
}
CSS代码片段的更多相关文章
- 30+有用的CSS代码片段
在一篇文章中收集所有的CSS代码片段几乎是不可能的事情,但是我们这里列出了一些相对于其他的更有用的代码片段,不要被这些代码的长度所吓到,因为它们都很容易实现,并且具有良好的文档.除了那些解决常见的恼人 ...
- HTML/CSS代码片段
内容简介:本文收集了我常用的CSS代码片段! *reset @charset "utf-8"; /* reset */ body, dl, dd, h1, h2, h3, h4, ...
- 【转】30+有用的CSS代码片段
来自:WEB资源网 链接:http://webres.wang/31-css-code-snippets-to-make-you-a-better-coder/ 原文:http://www.desig ...
- 实用的60个CSS代码片段
1.垂直对齐 如果你用CSS,则你会有困惑:我该怎么垂直对齐容器中的元素?现在,利用CSS3的Transform,可以很优雅的解决这个困惑: .verticalcenter{ position: re ...
- 60个有用CSS代码片段
1.垂直对齐 如果你用CSS,则你会有困惑:我该怎么垂直对齐容器中的元素?现在,利用CSS3的Transform,可以很优雅的解决这个困惑: .verticalcenter{ position: re ...
- 拥有的50个CSS代码片段(上)
1. CSS 重置 ;;;font-size: 100%; font: inherit; vertical-align: baseline; outline: none; -webkit-box-si ...
- (转)每位设计师都应该拥有的50个CSS代码片段
原文地址:http://www.cnblogs.com/fengyuqing/archive/2013/06/15/css_50.html 面对每年如此多的 新趋势 ,保持行业的领先是个很困难问题. ...
- 很实用的50个CSS代码片段
原文:50 Useful CSS Snippets Every Designer Should Have 面对每年如此多的 新趋势 ,保持行业的率先是个非常困难问题. 站点设计者和前 ...
- Css学习总结(2)——60个有用CSS代码片段
1.垂直对齐 如果你用CSS,则你会有困惑:我该怎么垂直对齐容器中的元素?现在,利用CSS3的Transform,可以很优雅的解决这个困惑: .verticalcenter{ position: re ...
- 实用的60个CSS代码片段[上]
1.垂直对齐 如果你用CSS,则你会有困惑:我该怎么垂直对齐容器中的元素?现在,利用CSS3的Transform,可以很优雅的解决这个困惑: .verticalcenter{ position: re ...
随机推荐
- mysql查看编码格式以及修改编码格式
1.进入mysql,输入show variables like 'character%';查看当前字符集编码情况,显示如下: 其中,character_set_client为客户端编码方式: char ...
- 高德地图JS API获取经纬度,根据经纬度获取城市
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...
- 微信小程序 + mock.js 实现后台模拟及调试
一.创建小程序项目 mock.js 从 https://github.com/nuysoft/Mock/blob/refactoring/dist/mock.js 下载 api.js:配置模拟数据和后 ...
- [SQL]LeetCode178. 分数排名 | Rank Scores
Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ra ...
- [Swift]LeetCode373. 查找和最小的K对数字 | Find K Pairs with Smallest Sums
You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define ...
- [Swift]LeetCode453. 最小移动次数使数组元素相等 | Minimum Moves to Equal Array Elements
Given a non-empty integer array of size n, find the minimum number of moves required to make all arr ...
- [Swift]LeetCode664. 奇怪的打印机 | Strange Printer
There is a strange printer with the following two special requirements: The printer can only print a ...
- [Swift]LeetCode883. 三维形体投影面积 | Projection Area of 3D Shapes
On a N * N grid, we place some 1 * 1 * 1 cubes that are axis-aligned with the x, y, and z axes. Each ...
- 【译】编写支持SSR的通用组件指南
原文来自:https://blog.lichter.io/posts/the-guide-to-write-universal-ssr-ready-vue-compon?utm_campaign=Vu ...
- apollo客户端springboot实战(四)
1. apollo客户端springboot实战(四) 1.1. 前言 经过前几张入门学习,基本已经完成了apollo环境的搭建和简单客户端例子,但我们现在流行的通常是springboot的客户端 ...