This is MY demo Work in JSFIDDLE  NB without using table property    I want to make the class .box should be vertically centered  CSS  .main{ height:300px; border:1px red solid;position:relative} .box{width:40px; height:40px; background:red; }  /* for centering */ .box{ display: inline-block;position:relative; top:50% } .main{ text-align: center; }   HTML  &lt;div class="main"&gt;   &lt;div class="box"&gt;&lt;/div&gt;    &lt;/div&gt;
173
I want to center a div vertically with CSS. I don't want tables or JavaScript, but only pure CSS. I found some solutions, but all of them are missing Internet Explorer 6 support. &lt;body&gt;     &lt;div&gt;Div to be aligned vertically&lt;/div&gt; &lt;/body&gt;  How can I center a div vertically in all major browsers, including Internet Explorer 6?
97365
I'm trying to get some console output in my homework. I put it in a listings environment but I want it to be centered horizontally on the page.  The only thing I get centered is the caption ;-/  \begin{minipage}{1\textwidth} \begin{center} \begin{lstlisting}[caption={Ausgabe des C-Programms},label={ggt_c_ausgabe}] a  |  b  |  q  |  u  |  s  |  v  |  t   ---------------------------------------- 78 |  21 |   1 |     |   1 |   1 |  -1  21 |  15 |   3 |   1 |  -3 |  -1 |   4  15 |   6 |   1 |  -3 |   4 |   4 |  -5   6 |   3 |   2 |   4 | -11 |  -5 |  14   3 |     |   2 | -11 |  26 |  14 | -33  ---------------------------------------- \end{lstlisting} \end{center} \end{minipage}
555
I have a div with two images and an h1. All of them need to be vertically aligned within the div, next to each other. One of the images needs to be absolute positioned within the div. What is the CSS needed for this to work on all common browsers? &lt;div id=&quot;header&quot;&gt;   &lt;img src=&quot;..&quot; &gt;&lt;/img&gt;   &lt;h1&gt;testing...&lt;/h1&gt;   &lt;img src=&quot;...&quot;&gt;&lt;/img&gt; &lt;/div&gt;
78193
I want to show a table of fixed width at the center of browser window. Now I use  &lt;table width="200" align="center"&gt;    But Visual Studio 2008 gives warning on this line:  Attribute 'align' is considered outdated. A newer construct is recommended.  What CSS style should I apply to the table to obtain the same layout?
112335
Lets say I have a text box that I want to fill a whole line. I would give it a style like this:  input.wide {display:block; width: 100%}   This causes problems because the width is based on the content of the text box. Text boxes have margin, borders, &amp; padding by default, which makes a 100% width text box larger than its container.  For example, here on the right:    Is there any way to make a text box fill the width of its container without expanding beyond it?  Here is some example HTML to show what I mean:  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; &lt;head&gt;     &lt;title&gt;Untitled Page&lt;/title&gt;     &lt;style type="text/css"&gt;         #outer{border: 1px solid #000; width: 320px; margin: 0px;padding:0px}         #inner{margin: 20px; padding: 20px; background: #999;border: 1px solid #000;}         input.wide {display:block; margin: 0px}         input.normal {display:block; float: right}     &lt;/style&gt; &lt;/head&gt; &lt;body&gt;     &lt;div id="outer"&gt;         &lt;div id="inner"&gt;             &lt;input type="text" class="wide" /&gt;             &lt;input type="text" class="normal" /&gt;             &lt;div style="clear:both;"&gt;&lt;/div&gt;         &lt;/div&gt;     &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;   If this is run, you can see by looking at the "normal" text box that the "wide" text box is sticking out beyond the container. The "normal" text box floats to the actual edge of the container. I'm trying to make the "wide" text box fill its container, without expanding beyond edge like the "normal" text box is.
121259
I have the following table:  \begin{tabular}{|p{3cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|} \hline \centerline {image}  &amp;    \multicolumn{2}{c|}{ABC} &amp; \multicolumn{2}{c|}{DEF} \\ \hline  &amp; \centering A&amp;\centering B&amp;\centering C&amp;\centering D  \\ \hline \centerline 1&amp;&amp;&amp;&amp; \\ \hline \centerline 1&amp;&amp;&amp;&amp; \\ \hline \centerline 1&amp;&amp;&amp;&amp; \\ \hline \centerline 1&amp;&amp;&amp;&amp; \\ \hline \end{tabular}   When I try centering D, I have a problem in the shape of the table. Why is that? How can I center it appropriately?  Thanks.
6298
Best way to center a &lt;div&gt; element on a page both vertically and horizontally?  I know that margin-left: auto; margin-right: auto; will center on the horizontal, but what is the best way to do it vertically, too?
26668
I have a rather wide table for which I have a designated page in landscape mode. The rest of the document is in portrait mode. Currently, the first row of the table begins at the very top of the page and ends somewhere in the middle. I'd like the table to be vertically centered though. How can I achieve this? I'm using the tabular environment.
98559
I'd like to create a new column type which works exactly like a X column from tabularx but that also has the text vertically centered. I tried with the newcolumntype command but I can't figure out where to put the second column type? Example:  \newcolumntype{n}{&gt;{\centering\arraybackslash}X}   Where should I put the mto specify that the cells content should be vertically centered?
45029
I would like to create a table with some columns' width specified, while the text in those columns should be centered both horizontally and vertically. I found out that  \usepackage{array} \begin{tabular}{| c | c | m{5cm} |}   vertically centers the text in the last column, but justifies it horizontally (like text in normal paragraphs).  Update: With Jake's method, it seems both \\ and \hline cause an error. How to fix it?
38286
Problem:  I have searched how you can align text without the use of tables using LaTex. What I am after is to align images after each other on one side and text to align to respective image on the right hand side.  Example of problem:    Desired outcome:  Basically I am after to be able to align a photo and corresponding text exactly aligned horizontally to the middle of that photo. Each photo/text part should be divided by an arrow which is exactly aligned vertically in the middle of each photo.  I would appreciate if someone could give advice what the best practice is without using any tables.
73184
I can't figure out how to achieve the following layout with CSS (probably because I don't actually know CSS).  I have a bunch of divs like this:  &lt;div class="right"&gt; &lt;p&gt;1&lt;/p&gt; &lt;/div&gt; &lt;div class="left"&gt;  &lt;p&gt;2&lt;/p&gt; &lt;/div&gt; &lt;div class="left"&gt;  &lt;p&gt;3&lt;/p&gt; &lt;/div&gt; &lt;div class="left"&gt;  &lt;p&gt;4&lt;/p&gt; &lt;/div&gt; &lt;div class="right"&gt; &lt;p&gt;5&lt;/p&gt; &lt;/div&gt; &lt;div class="right"&gt; &lt;p&gt;6&lt;/p&gt; &lt;/div&gt;   (not the real contents)  Now I want the layout to look like two equal columns of divs, with the "right" ones on the right, and the "left" ones on the left, thus:  2 1 3 5 4 6   [Edit: In a previous version of this question I had textareas inside the divs, and the divs all had different names like "one" and "xyz".] I tried something like  div.right { width:50%; float:right; clear:right; } div.left { width:50%; float:left; clear:left;}   but it doesn't quite work: It produces something like:  2 1 3  4 5   6   (without the "clear"s, it blithely produces   2 1 3 4 6 5   which is not what is wanted).  It is apparent that it can be made to work if the divs are ordered differently, but I'd like not to do that (because these divs are generated dynamically if the browser has Javascript, and I don't want to change the actual order that is displayed in the absence of Javascript, for semantic reasons). Is it still possible to achieve the layout I want?  [For what it's worth, I'm willing to have it not work on IE or older versions of other browsers, so if there is a solution that works only on standards-compliant browsers, that's okay :-)]
16910
I have a page structure similar to this:  &lt;body&gt;   &lt;div id="parent"&gt;     &lt;div id="childRightCol"&gt;       /*Content*/     &lt;/div&gt;     &lt;div id="childLeftCol"&gt;       /*Content*/     &lt;/div&gt;   &lt;/div&gt; &lt;/body&gt;   I would like for the parent div to expand in height when the inner div's height increases.  Edit: One problem is that if the width of the child content expands past the width of the browser window, my current CSS puts a horizontal scrollbar on the parent div.  I would like the scrollbar to be at the page level. Currently my parent div is set to overflow: auto;  Can you please help me with the CSS for this?
37762
I have a document containing a table which is slightly too wide for the page. But instead of growing to the right side only, I would like to have it centered on the page.  I have tried to use the center environment but this doesn't seem to help.
4125
I want to create a table with multiple rows of the following form: a cell that contains text and then multiple cells that contain images. The text should be vertically centered and the contents of every column should also be centered horizontally. I am aware of the m{} column type but somehow this seems to fail if an image is contained in the row and determines the row height. Any ideas?  Minimal example:  \documentclass{article} \usepackage{graphicx} \usepackage{array} \begin{document} \begin{figure} \begin{tabular}{m{3cm}c} (a) &amp; \includegraphics{some_picture.pdf}\\ \end{tabular} \end{figure}  \end{document}
84421
I'm trying to create a multi-page table with all cells having the same height (as well as certain fixed widths) so that certain manual cut-and-paste operations are a lot easier.  One issue is that one column in particular is text-heavy and should line-break within the cell.  As I don't want it justified, I looked into alternatives such as .  This is doing exactly what I want for horizontal alignment.  For vertical alignment, I've looked at  and the \vphantom method detailed in the above link doesn't seem to be working.  Here's what I'm currently working with:  \documentclass[11pt]{article} \usepackage{array}  \newcolumntype{P}[1]{&gt;{\raggedright\hspace{0pt}\arraybackslash}p{#1}} \def\Z{\vphantom{\parbox[c]{1.7in}{\Huge Something Long}}}  \begin{document} \begin{tabular}{| c || P{0.5in} || P{0.5in} || P{5in} |}\hline  1.  \Z &amp;&amp;&amp; Long long long long long long long long long             long long long long long long long text  \\\hline 2.  \Z &amp;&amp;&amp; More long long long long long long long long             long long long long long long long text  \\\hline \end{tabular}   When I compile, the cells do not have a uniform height, and none of them are as large as 1.7 inches vertically.  So this suggests that somehow the \vphantom method is failing.  Does anybody know of a relatively straightforward solution to this problem?
100316
I have the following problem. I want to center a listing, I tried this approach:   It works but when I try to set frame or numbers specifically for each listing I get errors. Here´s the M(Not)WE:  \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{listings} \begin{document}  \begin{figure}[thp]  \begin{tabular}{c}   \begin{lstlisting}[numbers=left] % Here lies the problem without the numbers=left it works    My Code   \end{lstlisting}  \end{tabular}  \centering  \caption{Bla} \end{figure}  \end{document}   Is there another way to center the listings and captions or how could I fix this approach?