我無法在我的頁面正中央將div class「bubblewrap」居中。請告訴我如何。我目前使用的方法通常不起作用。如何用css將我的對象放在我的頁面中心?
body {
background-color: black;
}
.bubble
{
position: relative;
width: 200px;
height: 70px;
padding: 0px;
background: #FFFFFF;
-webkit-border-radius: 0px;
-moz-border-radius:0px;
border-radius: 0px;
margin-left:10px;
margin-top:10px;
}
.bubble:after
{
content: '';
position: absolute;
border-style: solid;
border-width: 9px 16px 9px 0;
border-color: transparent white;
display: block;
width: 0;
z-index: 1;
left: -16px;
top: 26px;
}
.oddbubble
{
position: relative;
width: 200px;
height: 70px;
padding: 0px;
background: #FFFFFF;
-webkit-border-radius: 0px;
-moz-border-radius: 0px;
border-radius: 0px;
margin-top:10px;
}
.oddbubble:after
{
content: '';
position: absolute;
border-style: solid;
border-width: 9px 0 9px 16px;
border-color: transparent #FFFFFF;
display: block;
width: 0;
z-index: 1;
right: -16px;
top: 26px;
}
.bubblewrap {
margin:auto;
position:absolute;
top:0; bottom:0; left:0; right:0;
}
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<link href="bubble.css" type="text/css" rel="stylesheet">
</head>
<body>
<div class="bubblewrap">
<div class="bubble"></div>
<div class="oddbubble"></div>
<div class="bubble"></div>
<div class="oddbubble"></div>
</div>
</body>
</html>
我認爲這個問題是我的定位,但不能肯定的事。