草庐IT

绝对化

全部标签

html - 将绝对 div 定位在屏幕 View 的中心

我想将具有绝对位置的div放置在屏幕View的中心(滚动或不滚动)。我有这个,但是它把div放在文档的中间而不是当前View的中间。#main{width:140px;height:100px;border:1pxsolidBlack;text-align:left;position:absolute;top:50%;left:50%;margin-left:-70px;margin-top:-50px;} 最佳答案 使用以下CSS:.centered{position:fixed;top:50%;left:50%;/*bringy

html - 将绝对 div 定位在屏幕 View 的中心

我想将具有绝对位置的div放置在屏幕View的中心(滚动或不滚动)。我有这个,但是它把div放在文档的中间而不是当前View的中间。#main{width:140px;height:100px;border:1pxsolidBlack;text-align:left;position:absolute;top:50%;left:50%;margin-left:-70px;margin-top:-50px;} 最佳答案 使用以下CSS:.centered{position:fixed;top:50%;left:50%;/*bringy

html - CSS 绝对居中

最近我遇到了这种方法,它用于将元素水平和垂直定位到中心。但是,我无法弄清楚每个属性在做什么。有人可以向我解释设置top:0,bottom:0,left:0,right:0有什么影响吗?(如果您能够用通俗易懂的术语解释它或提供说明性图像,那就太好了。)还有,设置display为table有什么用?.absolute-center{position:absolute;display:table;height:auto;width:500px;margin:auto;top:0;bottom:0;right:0;left:0;border:solid1pxred;}Whatisthissor

html - CSS 绝对居中

最近我遇到了这种方法,它用于将元素水平和垂直定位到中心。但是,我无法弄清楚每个属性在做什么。有人可以向我解释设置top:0,bottom:0,left:0,right:0有什么影响吗?(如果您能够用通俗易懂的术语解释它或提供说明性图像,那就太好了。)还有,设置display为table有什么用?.absolute-center{position:absolute;display:table;height:auto;width:500px;margin:auto;top:0;bottom:0;right:0;left:0;border:solid1pxred;}Whatisthissor

html - CSS位置绝对和全 Angular 问题

我有2个div和一个dl:这是我的风格:#wrap{margin:0auto;width:100%;min-width:760px;max-width:1003px;overflow:hidden;}#header{width:100%;position:relative;float:left;padding-top:18px;margin-bottom:29px;}#site_nav_global_primary{float:right;margin-right:18px;margin-bottom:11px;margin-left:18px;}现在我想将site_nav_globa

html - CSS位置绝对和全 Angular 问题

我有2个div和一个dl:这是我的风格:#wrap{margin:0auto;width:100%;min-width:760px;max-width:1003px;overflow:hidden;}#header{width:100%;position:relative;float:left;padding-top:18px;margin-bottom:29px;}#site_nav_global_primary{float:right;margin-right:18px;margin-bottom:11px;margin-left:18px;}现在我想将site_nav_globa

html - CSS 绝对位置不适用于 margin-left :auto margin-right: auto

假设您将以下CSS应用于div标签.divtagABS{position:absolute;margin-left:auto;margin-right:auto;}margin-left和margin-right不生效但如果你有亲戚,它工作正常即.divtagREL{position:relative;margin-left:auto;margin-right:auto;}这是为什么呢?我只想让一个元素居中。有人可以解释为什么在绝对位置将边距设置为auto不起作用吗? 最佳答案 编辑:这个答案曾经声称不可能使用margin:auto

html - CSS 绝对位置不适用于 margin-left :auto margin-right: auto

假设您将以下CSS应用于div标签.divtagABS{position:absolute;margin-left:auto;margin-right:auto;}margin-left和margin-right不生效但如果你有亲戚,它工作正常即.divtagREL{position:relative;margin-left:auto;margin-right:auto;}这是为什么呢?我只想让一个元素居中。有人可以解释为什么在绝对位置将边距设置为auto不起作用吗? 最佳答案 编辑:这个答案曾经声称不可能使用margin:auto

html - 位置绝对+滚动

使用以下HTML和CSS.container{position:relative;border:solid1pxred;height:256px;width:256px;overflow:auto;}.full-height{position:absolute;top:0;left:0;right:128px;bottom:0;background:blue;}内部div根据需要占据容器的整个头部。如果我现在向容器中添加一些其他的流内容,例如:.container{position:relative;border:solid1pxred;height:256px;width:256px

html - 位置绝对+滚动

使用以下HTML和CSS.container{position:relative;border:solid1pxred;height:256px;width:256px;overflow:auto;}.full-height{position:absolute;top:0;left:0;right:128px;bottom:0;background:blue;}内部div根据需要占据容器的整个头部。如果我现在向容器中添加一些其他的流内容,例如:.container{position:relative;border:solid1pxred;height:256px;width:256px