Solved

Horizontally Centering an image

Posted on 2012-04-03
1
164 Views
Last Modified: 2012-04-03
Hello Experts,

Example

I want to horizontally center the red image within the yellow rectangle.
Is it possible to do this just by editing the basket-title class?

Thanks
0
Comment
Question by:jagku
[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
1 Comment
 
LVL 30

Accepted Solution

by:
LZ1 earned 500 total points
ID: 37802539
Yes, but you would need to have margin:15px auto;.  To center a block level element like that, you need to have your left and right margins be auto and a fixed width also.

Make sense?  But since you have things overriding the margin-left & margin-right declarations in the basket-title class, you would need to add !important to the CSS.

Like so:

.basket-title {
    background: url("myimage.png") no-repeat scroll 0 0 transparent;
    margin-left: auto !important;
    margin-right: auto !important;
    width: 50%;
}

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

This is a how to build your own CSS3 slideshow and when I say CSS3 I mean just CSS with no javascript in sight! There a few examples online of how to do this but most just show you an example without any explanation, others make it more complicat…
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 to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

733 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