Have a nice Day,
i tried to use vertical-align property of css in one of my project, but it did not work at all. can anybody tell me how can we use this property properly or any other alternative technique.
thanks in advance
Have a nice Day,
i tried to use vertical-align property of css in one of my project, but it did not work at all. can anybody tell me how can we use this property properly or any other alternative technique.
thanks in advance
For : this thread shows the common confusion around vertical centering. correctly flagged that the property you tried is often misapplied, experimented with a value, and 's caution about cross-browser quirks reflects the era this thread started in. Today, prefer layout techniques that are explicit about the container and the axis you want to center on.
Use one of these reliable patterns depending on needs.
/* Flexbox — best for general layouts and responsiveness */
.container {
display: flex;
align-items: center; /* vertical centering */
justify-content: center;/* horizontal centering */
height: 200px;
} /* Grid — concise for both axes */
.container {
display: grid;
place-items: center;
height: 200px;
} /* Absolute + transform — good for a single element inside a known-size parent */
.parent { position: relative; height: 200px; }
.child {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
} /* Line-height trick — only for single-line text */
.single-line { height: 48px; line-height: 48px; } Troubleshooting notes: always confirm the container has a defined height (or uses viewport units), and check the child element display type (images are inline by default). For older browsers use table-cell fallbacks or a small JS polyfill. For reference and compatibility details see vertical-align - MDN and Centering in CSS — CSS-Tricks.
Jump to Post— sreein1986 0.sree { vertical-align: text-top; }
Jump to Post— sreein1986 0Here found this, maybe both you and sree should read it, it will help you both out i am sure.
http://www.ibloomstudios.com/articles/vertical-align_misuse/
this code also working
please check it ...
What are you trying to achive with vertical-align?
i want to set images/text in center of block.
Ok in that case it's not vertical-align you need to use. vertical-align will align an elements withing an inline-level or a tabel cell.
eg. If you wanted to align an image above or below a line of text if that image is inline with that text.
I asume you have come accross centering an image horizontialy in css? You would use the same method in vertical alignment.
#blah {
position: relative;
margin-top: auto;
margin-bottom: auto;
// Plus all the other usual ie workarounds etc.
} .sree {
vertical-align: text-top;
} Here found this, maybe both you and sree should read it, it will help you both out i am sure.
http://www.ibloomstudios.com/articles/vertical-align_misuse/
Here found this, maybe both you and sree should read it, it will help you both out i am sure.
http://www.ibloomstudios.com/articles/vertical-align_misuse/
this code also working
please check it ...
Yeah it's not ment to be used like that!
Do not expect to center things vertically in the browser window. It won't work on all browsers or all screen resolutions.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.