shape - How to center a CSS Hexagon -


Not sure how to centrally focus this hexagon, setting margin: auto; Thank you in advance, if someone can help the whole shape is not grateful.

  .hexagon {position: absolute; Width: 300px; Height: 173.21 pixels; Background color: #fff; } .hexagon: First, .hexagon: after {content: ""; Status: Completed; Margin-left: auto; Margin-right: auto; Border-left: 150px solid transparent; Boundary-right: 150px solid transparent; }. Hexagon: first {bottom: 100%; Border Bottom: 86.60px solid #fff; Status: Completed; Margin-left: auto; Margin-right: auto; } .hexagon: after {status: absolute; top 100%; Width: 0; Border-top: 86.60px solid #fff; }  

margin: auto will not work if you use hexagon To fully integrate the devices, you need to add top: 50% , left: 50% and margins: -86.6px 0 0 -150px . -86.6 px is half of your hexagon and half of -150px width; apart from this, you have to make your original position relative to the height of 100%.

HTML

  & lt; Div class = "hexagon" & gt; & Lt; / Div & gt;  

CSS

  html, body {background-color: # 333; Height: 100%; Width: 100%; Status: Relative; } .hexagon {top: 50%; Left: 50%; Margin: -86.6px 0 -150px; }  


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -