Solved

CSS - how to center horizontal and vertical  image + text

Posted on 2014-12-20
2
99 Views
Last Modified: 2014-12-20
How can I center vertical and horizontally  in a div  and image and text

                           <div >
                                <img src="graphics/tools.png" class="imgIcon" alt="" />
                                <p><strong><a href="tools.htm">Tools</a></strong></p>
                            </div>
0
Comment
Question by:JElster
2 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 350 total points
ID: 40511044
div {
    display:table-cell;
    height:150px; 
    vertical-align:middle;
    text-align:center
}

Open in new window


http://jsfiddle.net/d773dghs/2/
0
 
LVL 8

Assisted Solution

by:albacom
albacom earned 150 total points
ID: 40511065
You can add the following to the head section of the html page:

<style  type="text/css">

div{
	margin:0 auto;
	width:100px;
	height:100px;
	padding:20px;	
	background:#09F;
}
div img{
	display:block;
	width:100px;
	height:100px;
}
div p{
	display:block;
	margin:0 auto;
	text-align:center;
	color:#fff;
}

</style>

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Remove Space when printing webpage - Setup in Print.css 3 30
Fix Form size HTML 16 31
Popup write two lines 3 22
Increase image taller on inner pages 2 18
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question