We help IT Professionals succeed at work.
Get Started

CSS question -- center inside a div using percentages

Eric Bourland
Last Modified: 2016-03-03
Good morning. Next silly question. =) I have two CSS problems at the moment; I've been struggling with these for a while.

1) I want to form a square DIV and center the text inside it -- using percentages rather than ems or px -- but the text does not quite want to center; the text looks shifted to the right?

2) And then, I would like the text and background image to scale when I scale the browser window -- shrink when the window gets smaller.

It's been a while since I did PSD to HTML and I am struggling a little.

What am I missing? Thank you very much for any advice.


Test page: http://www.cep-dc.org/test.cfm

The CSS:

.fpbluebox_latest {
background: ‪#‎98dafc‬ url(/img/CEP-latest-icon-fp.png) 50% 23% no-repeat;

.fpbluebox_latest p {
font:normal 120% 'Open Sans', 'Oswald', sans-serif;
position: relative;
top: 2.6em;
border:1px solid #000;
Watch Question
This problem has been solved!
Unlock 3 Answers and 9 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