Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9004105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:49:36+00:00 2026-06-16T00:49:36+00:00

How do you align a background icon image if the text is center-aligned? Like

  • 0

How do you align a background icon image if the text is center-aligned? Like a small icon before the text. If it’s not center-aligned, I can use something like:

p { 
  background: url(image.jpg) no-repeat 0 0;
  padding-left: 40px;
}

But if I center align it like so:

p { 
  background: url(image.jpg) no-repeat 0 0;
  padding-left: 40px;
  text-align: center;
}

The background remains on the left corner while the text is centered (so there’s a huge gap in between them). It’s possible to use background position, however, if the screen is of a different size than what I use, the background will be overlapped by the text.

You can check the jsFiddle demo:

http://jsfiddle.net/PvL3T/2/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:49:38+00:00Added an answer on June 16, 2026 at 12:49 am

    :first-letter pseudo element will play around good, http://jsfiddle.net/PvL3T/7/

    p { 
      padding-left: 40px;
      text-align: center;
    }
    
    .resize:first-letter { 
       background: url(http://www.torontorawveganfestival.com/Images/Pen-icon.png) no-repeat 0 50%; padding-left: 20px;
    }
    

    this will work even into IE6 if you care, but only if there is white space between selector and opening curve bracket. Only for IE6 something like this p:first-letter{... will not work, but p:first-letter {... will

    and just in similar way, you may use :first-line

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the CSS Sprite Technique with a background image that looks something like
I saw this selector in Twitter Bootstrap: .show-grid [class*=span] { background-color: #eee; text-align: center;
How can I center align (horizontally) an image inside its container div? Here's the
<div style=width:100%;background-color: #61b832;border-radius: 10px;color:white;text-align: center>Videos List</div> <table style=width:100%;id=videoTable> <c:forEach items=${requestScope.userInfo.videoList}var=videovarStatus=0> <script> var fullvideoUrl='<c:out value=${video.videoUrl}></c:out>';
In master page Script: $(.RightMenu).click(function(){ $(.FlashMenu).css('background-image','url(icon/PersonalPage/blueFlash30.png)'); $('.RightMenu').css('background-image','url(icon/PersonalPage/Menu.png)'); $(this).css('background-image','url(icon/PersonalPage/MenuActive.png)'); $(this).css('background-repeat','repeat-x'); $(this).find(>:first-child).css('background-image','url(icon/PersonalPage/greenflash30.png)'); $(this).find(>:first-child).css('background-repeat','no-repeat'); }); $(.RightMenu).mouseover(function(){ $('.RightMenu').css('background-image','url(icon/PersonalPage/Menu.png)');
How can I set a jquery ui icon as a background image per a
I want align the div to center. like this I have tried margin-top, vertical-align
I try to align an image (a logo) with a text in two lines
I would like to have a Text plus image button in a row. if
I have a button with a background-image property that sets 1) an icon for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.