【发布时间】:2017-06-12 23:25:18
【问题描述】:
我正在尝试将此模式消息设置为居中,但它总是落在左侧,我尝试使用 margin: 0 auto; float: center 或 left: 0 和 right: 0 但这不起作用。
.descrizione {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
transition: opacity 400ms;
}
.descrizione .cancel {
position: absolute;
width: 100%;
height: 100%;
cursor: default;
}
.descrizione:target {
visibility: visible;
opacity: 0;
animation: animationFrames ease 1s;
animation-iteration-count: 1;
transform-origin: 50% 50%;
animation-fill-mode: forwards;
-webkit-animation: animationFrames ease 1s;
-webkit-animation-iteration-count: 1;
-webkit-transform-origin: 50% 50%;
-webkit-animation-fill-mode: forwards;
-moz-animation: animationFrames ease 1s;
-moz-animation-iteration-count: 1;
-moz-transform-origin: 50% 50%;
-moz-animation-fill-mode: forwards;
-o-animation: animationFrames ease 1s;
-o-animation-iteration-count: 1;
-o-transform-origin: 50% 50%;
-o-animation-fill-mode: forwards;
-ms-animation: animationFrames ease 1s;
-ms-animation-iteration-count: 1; -ms-transform-origin: 50% 50%;
-ms-animation-fill-mode: forwards;
}
.messaggio {
z-index: 9999;
padding: 20px;
background: #fff;
border: 1px solid #666;
width: 300px;
box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
position: relative;
}
.light .messaggio {
border-color: #aaa;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.messaggio h2 {
margin-top: 0px;
color: #666;
text-transform: uppercase;
border-bottom: 2px solid #2767ce;
font-family: "Trebuchet MS", Tahoma, Arial, sans-serif;
}
.messaggio .chiudi {
position: absolute;
width: 20px;
height: 20px;
top: 20px;
right: 20px;
opacity: 0.8;
transition: all 200ms;
font-size: 24px;
font-weight: bold;
text-decoration: none;
color: #666;
}
.messaggio .chiudi:hover {
opacity: 1;
display: block;
}
.messaggio .testo {
max-height: 400px;
overflow: auto;
font-family: sans-serif;
font-size: 16px;
}
.messaggio p {
margin: 0 0 1em;
}
.messaggio p:last-child {
margin: 0;
}
<div class="descrizione" id="hub">
<div class="messaggio">
<h2>hub</h2>
<a class="chiudi" href="#">×</a>
<div class="testo">
<p>Questa è una breve descrizione che deve essere modificate dal propietario della pagina di mc-ita, si prega di modificarla al più presto</p>
</div>
</div>
</div>
PS:点击按钮后会出现此消息。
【问题讨论】:
-
您是否尝试过添加一个宽度为 100% 的包含 div,然后将 margin: auto 放在描述 div 上?
-
您说您尝试了
margin: 0 auto,但添加.messaggio { margin: 0 auto; }居中....您是说这不起作用? -
是的迈克尔科克
-
是的乔纳森荷兰
-
@Lafa:要在此处 ping 用户,您必须使用带有用户名的
@。选项卡完成可用。您可以快速编辑这些消息,也可以删除它们并重新发布。
标签: html css simplemodal