ਕਿਵੇਂ div ਵਿੱਚ ਬਟਨ ਨੂੰ ਮੱਧਮ ਸਥਾਨ ਰੱਖਣਾ

CSS ਦੀ ਮਦਦ ਨਾਲ ਬਟਨ ਅੰਗਾਮੇ ਦੀ ਉੱਚ ਅਤੇ ਪੱਧਰੀ ਮੱਧਮ ਸਥਾਨ ਰੱਖਣ ਦੇ ਤਰੀਕੇ ਸਿੱਖੋ

ਕਿਵੇਂ ਬਟਨ ਨੂੰ ਉੱਚ ਮੱਧਮ ਸਥਾਨ ਰੱਖਣਾ

<style>
.container {
  height: 200px;
  position: relative;
  border: 3px solid green;
}
.vertical-center {
  margin: 0;
  position: absolute;
  top: 50%;
  -ms-transform: translateY(-50%);
  transform: translateY(-50%);
}
</style>
<div class="container">
  <div class="vertical-center">
    <button>ਮੱਧਮ ਬਟਨ</button>
  </div>
</div>

ਆਪਣੇ ਅਨੁਭਵ ਕਰੋ

ਕਿਵੇਂ ਉੱਚ ਅਤੇ ਪੱਧਰੀ ਮੱਧਮ ਸਥਾਨ ਰੱਖਣਾ

<style>
.container {
  height: 200px;
  position: relative;
  border: 3px solid green;
}
.center {
  margin: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}
</style>
<div class="container">
  <div class="center">
    <button>ਮੱਧਮ ਬਟਨ</button>
  </div>
</div>

ਆਪਣੇ ਅਨੁਭਵ ਕਰੋ

ਤੁਸੀਂ ਫਲੈਕਸਬਾਕਸ ਦੀ ਮਦਦ ਨਾਲ ਅੰਗਾਮੇ ਨੂੰ ਮੱਧਮ ਸਥਾਨ ਰੱਖ ਸਕਦੇ ਹੋ

ਇੰਸਟੈਂਸ

.center {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
  border: 3px solid green;
}

ਆਪਣੇ ਅਨੁਭਵ ਕਰੋ

ਸਬੰਧਤ ਪੰਨੇ

教程:CSS ਅਲਾਇਨ

教程:CSS ਟ੍ਰਾਂਸਫਾਰਮ

教程:CSS Flexbox