?
Solved

CSS - how to center horizontal and vertical  image + text

Posted on 2014-12-20
2
Medium Priority
?
108 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 1400 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 600 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

Industry Leaders: 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

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…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses
Course of the Month12 days, 11 hours left to enroll

777 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