Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.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
Jquery Can';t水平对齐按钮_Jquery_Html_Css - Fatal编程技术网

Jquery Can';t水平对齐按钮

Jquery Can';t水平对齐按钮,jquery,html,css,Jquery,Html,Css,我很难让一个按钮在我的div中居中。我可以让它向左对齐,但当我将它居中对齐时,它会向右移动。当我将其对齐时,它将越过容器对齐 HTML 试试这个 你必须尝试将按钮移到中间的过程。例如绝对位置、上/左50%、平移-50% .flip容器{ -webkit透视图:1000; -莫兹透视图:1000; -o型透视图:1000; 前景:1 000; } .flip容器:悬停.flipper, .flip-container.hover.flipper{ -webkit变换:旋转(180度); -莫兹

我很难让一个按钮在我的div中居中。我可以让它向左对齐,但当我将它居中对齐时,它会向右移动。当我将其对齐时,它将越过容器对齐

HTML


试试这个


你必须尝试将按钮移到中间的过程。例如绝对位置、上/左50%、平移-50%

.flip容器{
-webkit透视图:1000;
-莫兹透视图:1000;
-o型透视图:1000;
前景:1 000;
}
.flip容器:悬停.flipper,
.flip-container.hover.flipper{
-webkit变换:旋转(180度);
-莫兹变换:旋转(180度);
-o变换:旋转(180度);
变换:旋转(180度);
}
.翻转容器,
.前线,
.回来{
宽度:100%;
最小高度:100%;
最大宽度:100%;
最大高度:100%;
身高:0;
垫底:70%;
}
.鳍状肢{
-webkit转换:0.6s;
-webkit变换样式:保留-3d;
-moz跃迁:0.6s;
-moz变换样式:preserve-3d;
-o-转变:0.6s;
-o变换样式:preserve-3d;
过渡:0.6s;
变换样式:保留-3d;
位置:相对位置;
}
.前线,
.回来{
-webkit背面可见性:隐藏;
-moz背面可见性:隐藏;
-o-背面-可见性:隐藏;
背面可见性:隐藏;
位置:绝对位置;
排名:0;
左:100 ;;
}
.前线{
背景:url(http://pghpeople.com/wordpress/wp-content/uploads/2014/01/pittsburgh_headshot_f01a.jpg);
背景尺寸:封面;
背景重复:无重复;
背景位置:50%50%;
}
.回来{
-webkit变换:旋转(180度);
-莫兹变换:旋转(180度);
-o变换:旋转(180度);
变换:旋转(180度);
背景:#bd2d2c;
}
.socicon风格{
:链接{
颜色:#fff;
}
:悬停{
颜色:#ebebeb;
}
文字装饰:无;
字号:3em;
位置:绝对位置;
底部:6%;
左:0%;
右:0%;
文本对齐:居中;
}
.封号{
颜色:#fff;
字号:2em;
位置:绝对位置;
最高:14%;
左:0%;
右:0%;
文本对齐:居中;
}
.角色{
颜色:#fff;
字号:1.5em;
位置:绝对位置;
最高:30%;
左:0%;
右:0%;
文本对齐:居中;
}
.按钮{
边界:无;
填料:1米2米;
文字装饰:无;
字体大小:.9em;
-webkit转换持续时间:0.2s;
/*狩猎*/
过渡时间:0.2s;
光标:指针;
字体系列:proxima nova;
字号:600;
字母间距:.1米;
边界半径:2米;
位置:绝对位置;
最高:50%;
左:50%;
转换:翻译(-50%,-50%);
}
.中心化{
文本对齐:右对齐;
显示器:flex;
}
.按钮{
背景色:白色;
颜色:#bd2d2c!重要;
文本转换:大写;
文字装饰:无;
}
.按钮:悬停{
背景色:rgba(255、255、255、.9);
颜色:rgba(189,45,44,1);
文字装饰:无;
}

无名氏
首席执行官
尝试使用此代码

我实际上不知道白色容器的宽度,所以它更像是基于点击和试验的计算,但逻辑是你给容器加上50%的余量,然后减去容器宽度的一半,这样它就会被放在中心

语法:

 margin:clac(50% - **half the width of the conatiner**);

@AndreyFedorov我可以对你的答案说同样的话,没有什么是不好的,只要它在不给网站的其他元素带来问题的情况下工作,我认为你可以。但是android浏览器中不支持calc,而translate没有问题。建议将按钮的大小设置为百分比,则无需使用calc
.flip-container {
  -webkit-perspective: 1000;
  -moz-perspective: 1000;
  -o-perspective: 1000;
  perspective: 1000;
}

.flip-container:hover .flipper,
.flip-container.hover .flipper {
  -webkit-transform: rotateY(180deg);
  -moz-transform: rotateY(180deg);
  -o-transform: rotateY(180deg);
  transform: rotateY(180deg);
}

.flip-container,
.front,
.back {
  width: 100%;
  min-height: 100%;
  max-width: 100%;
  max-height: 100%;
  height: 0;
  padding-bottom: 70%;
}

.flipper {
  -webkit-transition: 0.6s;
  -webkit-transform-style: preserve-3d;
  -moz-transition: 0.6s;
  -moz-transform-style: preserve-3d;
  -o-transition: 0.6s;
  -o-transform-style: preserve-3d;
  transition: 0.6s;
  transform-style: preserve-3d;
  position: relative;
}

.front,
.back {
  -webkit-backface-visibility: hidden;
  -moz-backface-visibility: hidden;
  -o-backface-visibility: hidden;
  backface-visibility: hidden;
  position: absolute;
  top: 0;
  left: 100;
}

.front {
  background: url(http://pghpeople.com/wordpress/wp-content/uploads/2014/01/pittsburgh_headshot_f01a.jpg);
  background-size: cover;
  background-repeat: no-repeat;
  background-position: 50% 50%;
}

.back {
  -webkit-transform: rotateY(180deg);
  -moz-transform: rotateY(180deg);
  -o-transform: rotateY(180deg);
  transform: rotateY(180deg);
  background: #bd2d2c;
}

.socicon-style {
  :link {
    color: #fff;
  }
  :hover {
    color: #ebebeb;
  }
  text-decoration:none;
  font-size: 3em;
  position: absolute;
  bottom: 6%;
  left: 0%;
  right: 0%;
  text-align: center;
}

.back-title {
  color: #fff;
  font-size: 2em;
  position: absolute;
  top: 14%;
  left: 0%;
  right: 0%;
  text-align: center;
}

.role {
  color: #fff;
  font-size: 1.5em;
  position: absolute;
  top: 30%;
  left: 0%;
  right: 0%;
  text-align: center;
}

.button {
  border: none;
  padding: 1em 2em;
  text-decoration: none;
  position: absolute;
  font-size: .9em;
  -webkit-transition-duration: 0.2s;
  /* Safari */
  transition-duration: 0.2s;
  cursor: pointer;
  font-family: proxima-nova;
  font-weight: 600;
  letter-spacing: .1em;
  border-radius: .2em;
  top: 50%;
}

.centerize {
  text-align: right;
}

.button {
  background-color: white;
  color: #bd2d2c !important;
  text-transform: uppercase;
  text-decoration: none;
}

.button:hover {
  background-color: rgba(255, 255, 255, .9);
  color: rgba(189, 45, 44, 1);
  text-decoration: none;
}
.button {
    border: medium none;
    border-radius: 0.2em;
    cursor: pointer;
    font-family: proxima-nova;
    font-size: 0.9em;
    font-weight: 600;
    letter-spacing: 0.1em;
    padding: 1em 2em;
    text-decoration: none;
    transition-duration: 0.2s;
}

.centerize {
    margin-top: 25px;
    text-align: center;
}
.button {
  border: none;
  padding: 1em 2em;
  text-decoration: none;
  position: absolute;
  font-size: .9em;
  -webkit-transition-duration: 0.2s;
  /* Safari */
  transition-duration: 0.2s;
  cursor: pointer;
  font-family: proxima-nova;
  font-weight: 600;
  letter-spacing: .1em;
  border-radius: .2em;
  top: 50%;
}

.centerize {
  margin: calc(50% - 70px); 
}
 margin:clac(50% - **half the width of the conatiner**);