We help IT Professionals succeed at work.
Get Started

Center elements

Panos asked
Last Modified: 2014-05-15
Hello experts.
I have a parent div. Inside this i have a div with a bg image and a span that is positioned absolute to the child div.
The problem i have is to center the text (span) like the div. (the span is starting exactly in the middle of the parent div and the image is centered exactly to the parent  so that i get the text to the right.
Any help?
<div align="center" class="noresult">
   <div class="mainback noresultimg"></div>
   <span class="noresulttxt">MY text</span>

div.noresult{ width:100%;height:150px; position:relative;}
div.noresult div.noresultimg{background-position: -1130px 0px;
    height: 150px;
    width: 126px; 
	margin: 0px auto -1px auto; 
div.noresult span.noresulttxt{ font-size:14px;  
    position:absolute; top:90px;  
	color:#663333;white-space:nowrap; }

Open in new window

Watch Question
Top Expert 2014
This problem has been solved!
Unlock 2 Answers and 10 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE