ਕਿਵੇਂ 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 Flexbox