Solved

CSS - how to center horizontal and vertical  image + text

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
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…
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 navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…

948 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

19 Experts available now in Live!

Get 1:1 Help Now