Solved

CSS - how to center horizontal and vertical  image + text

Posted on 2014-12-20
2
92 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

This is a how to build your own CSS3 slideshow and when I say CSS3 I mean just CSS with no javascript in sight! There a few examples online of how to do this but most just show you an example without any explanation, others make it more complicat…
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now