Solved

CSS - how to center horizontal and vertical  image + text

Posted on 2014-12-20
2
103 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Unordered lists (HTML ul tags) are very handy to create menus of all types, shapes and sizes.  All it takes is a little knowledge of CSS and the possibilities are endless. First off, you should know the general format for menus created using the …
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…

696 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