Solved

Horizontally Centering an image

Posted on 2012-04-03
1
160 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
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CSS Scroll Issue 3 117
CSS Position not returning 2 55
How can I make the input automatically take the width of the column? 1 17
Center div containing a script 6 14
As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
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 customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

785 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