vertical-alignment

Center a H1 tag inside a DIV

a 夏天 提交于 2019-11-29 00:58:24
I have the following DIV inside a body tag: <div id="AlertDiv"><h1>Yes</h1></div> And these are their CSS classes: #AlertDiv { position:absolute; height: 51px; left: 365px; top: 198px; width: 62px; background-color:black; color:white; } #AlertDiv h1{ margin:auto; vertical-align:middle; } How can I align vertically and horizontally H1 inside DIV? AlertDiv will be bigger than H1. You can add line-height:51px to #AlertDiv h1 if you know it's only ever going to be one line. Also add text-align:center to #AlertDiv . #AlertDiv { top:198px; left:365px; width:62px; height:51px; color:white; position

Vertical-align: bottom not working

南楼画角 提交于 2019-11-28 22:16:34
问题 I thought vertical-align was supposed to work with inline elements. Yet for some reason everything in the gray div is aligned to the top , not the bottom. <div style="position:absolute; top:130px; right: 80px; width: 230px; background-color:Gray; height:30px;" class="defaultText" id="pager"> <span style="vertical-align:bottom;">Page Size:</span> <select style="vertical-align:bottom; font-size:8pt; margin-top: 0; margin-left:3px; height:16px; text-align:center;"> <option value="50">50</option>

vertical align center image in fixed size div

只谈情不闲聊 提交于 2019-11-28 21:16:00
问题 I have a div which is 145px X 145px. I have an img inside this dive. The img could be of any size (longest side being 130px). I would like the image to be centered vertically in the div. Everything that I have tried works in most browsers, but not IE7. I need something that will work in IE7. 回答1: You can replace the image by a background on the div like this : <div style="background:url(myimage.jpg) no-repeat center center"></div> 回答2: here's a cross-browser solution: <div class="img

How to vertically align Bootstrap v4 modal dialogs

寵の児 提交于 2019-11-28 18:46:44
Vertically center modal dialogues in Bootstrap 4. Note: The requirements below have been added to make it clear I am looking for a proper way to vertically center a Bootstrap modal, covering all possible cases, on all possible devices, in all browsers. In my case, I wanted it for a large SPA reusing the same modal throughout the app so I needed it to work in each case. It should: keep modal contents accessible, on all devices, even when taller than device height work on any device+browser combination with a market share larger than 1% not use display:table-cell or similar hacks (any layout-ing

How to vertically align div inside another div without display:table-cell

痴心易碎 提交于 2019-11-28 17:39:50
Ok this is the div structure. <div class="DivParent"> <a href="#"> <div class="DivWhichNeedToBeVerticallyAligned"></div> </a> </div> DivParent has fixed width and height values but DivWhichNeedToBeVerticallyAligned does not have fixed height values. If you make DivParent display:table-cell; you can vertically align DivWhichNeedToBeVerticallyAligned but i don't want to use that feature since it causes some mess. A href tag link should be same size with the divParent i mean whole divparent has to be clickable. like display:block. So are there any CSS way of vertically aligning or lightweight

CSS vertical alignment text inside li

老子叫甜甜 提交于 2019-11-28 16:55:57
I am displaying number of boxes in a row with fix height and width, generated from <li> tags. now I need to align the text in the vertical center. The CSS vertical-align has no impact, maybe I am missing something??? I am not looking for tricks using (margin, padding, line-height), these will not work because some text are long and will break into two lines. Please find the actual code: CSS code ul.catBlock{ width:960px; height: 270px; border:1px solid #ccc; } ul.catBlock li{ list-style: none; float:left; display:block; text-align: center; width:160px; height: 100px; } ul.catBlock li a{

Add vertical whitespace using Twitter Bootstrap?

那年仲夏 提交于 2019-11-28 16:45:58
What's the best way to add vertical whitespace using Twitter's Bootstrap? For example, let's say that I am creating a landing page and would like a bit (100px) of blank whitespace above and below a certain button. Obviously, I could create a certain class for that particular button. But, I would think that Bootstrap should have a DRY way of adding in vertical blank spaces. In Bootstrap 4 there are spacing utilites . Citing the documentation for used notation : Spacing utilities that apply to all breakpoints, from xs to xl , have no breakpoint abbreviation in them. This is because those classes

Vertical Centering some Text over an Image with Dynamic Height

时光总嘲笑我的痴心妄想 提交于 2019-11-28 14:17:45
For whatever reason I am really beating myself up with this... No doubt because of the lack of support for a real "proper" way of vertically centering anything. The Goal: Is to have a set of four images, each inside their own responsive columns. Each image has a white overlay, that when hovered reveals more of the image, as well as a title for each of the 4 images that is horizontally and vertically centered inside the image. I could easily achieve this if I set specific width/heights and stuck the image inside CSS rather than the HTML. For SEO reasons I want the image to be present in the

Vertically align inline block elements

試著忘記壹切 提交于 2019-11-28 13:39:06
I've got a checkbox group. Which are centrally aligned with checkboxes on top and text below. Here is what I mean : So I want to align So each checkbox + label is wrapped in a div with class choice . All choice divs are part of div with additional-info . choice divs are inline-block elements with fixed width. How do I align div choice to be in the same height as the first one? I've tried setting the additional-info position to relative and choice to absolute. But then they overlap each other so that wasn't good. Also tried setting the choice div display to inline but then the current layout

CSS - Line height property, how it works (simple)

不问归期 提交于 2019-11-28 13:35:43
So in this simple example I have as final result: This is a very simple question but I simply can't get my head around it. To achieve the vertical centering of the numbers I used: line-height:100px; Which works great and have been doing it trial and error basis. My question is specifically why the line-height:50px; just gets if half of the way. If the small div has a height of 100px and I an positioning relative to it, shouldn't the half of it center it to the half. This specially puzzles me since, when I center a div : I would use: margin:50px 0 0 50px; to get this: I realize this question