Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
中心CSS内容:“”;内部_Css - Fatal编程技术网

中心CSS内容:“”;内部

中心CSS内容:“”;内部,css,Css,我正在尝试垂直和水平居中放置内容:+;。在垂直方向上,我已经能够使用线条高度来完成这项工作。 然而,在水平方向上,我尝试使用绝对定位,然后用边距进行减法。但是没有起作用 这就是我所拥有的: html body div.body-container form div#composite-field button#fes-submit { position: absolute; float: none; clear: both; top: 0; right: 5%; width: 80px; h

我正在尝试垂直和水平居中放置内容:+;。在垂直方向上,我已经能够使用线条高度来完成这项工作。 然而,在水平方向上,我尝试使用绝对定位,然后用边距进行减法。但是没有起作用

这就是我所拥有的:

html body div.body-container form div#composite-field button#fes-submit {
 position: absolute; float: none; clear: both; top: 0; right: 5%;
 width: 80px; height: 100px; margin: 0; padding: 0; font-size: 42px;

 border: 0; border-radius: 0; outline: none; -webkit-appearance: none;
 background-color: #2e4856; color: #eab94e;
 z-index: 20;
}

html body div.body-container form div#composite-field button#fes-submit:before {        
 content: "+"; line-height: 100px; float: left;
 font-family: "Open Sans", sans-serif; font-weight: 700; font-size: 42px; letter-spacing: normal;
}

有什么想法吗?

如果使用绝对定位,最好使用文字标注属性,例如“上”、“下”、“左”、“右”,而不是使用边距。使用浮动也可能会反作用于您想要的定位,因此请尝试移除该位置。另一种选择可能是在左边或右边添加负边距。

解决了这个问题

content:"+";
line-height: 100px;
display: block;
margin: 0 auto;
在垂直方向上,我使用线条高度:;并水平显示:块;,页边距:0自动


我就是这么做的:top:50%;,左:50%;然后用边距减去。但这一切都被扭曲了。根本无法使其居中…忽略浮动。这只是因为我在测试一些东西;带%的绝对位置考虑整个视口。可以使用精确像素。它需要是百分比。。。该按钮更改悬停时的宽度。确保您的父元素的位置设置为相对-查看此帖子也可能有帮助-除非您还指定了宽度,否则边距:0自动不应工作。我已指定了宽度。它只是在悬停时从像素变为百分比。