Centering Elements in a DIV (CEDIV)


CEDIV:   SOLD       




I want to place an element  div(with position:absolute;) in the center of the window. But I'm having trouble doing so, because the width is unknown.

I tried the following CSS code, but it needs to be adjusted because the width is responsive.

.center {
  left: 50%;
  bottom: 5px;
}

How can I achieve this?

Solutip

Please use the following method

css

#content {
  position: absolute; 
  left: 0; 
  right: 0; 
  margin-left: auto; 
  margin-right: auto; 
  width: 100px; /* Need a specific value to work */
}

html

<body>
  <div>
    <div id="content">
      I'm the content
    </div>
  </div>
</body>

Post a Comment

Previous Next

نموذج الاتصال