[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Css/Jquery Center image in browser

Posted on 2010-09-17
10
Medium Priority
?
711 Views
Last Modified: 2012-05-10
I have a jquery slide show, but i need center images in browser:

Html:
<div class="header_blog">
      <!-- * * * Banner -->
         
                <div id="slideshow">
                    <img src="images/banner/banner1.png" align="middle" alt="Slideshow Image 1" class="active"/>
                    <img src="images/Banner/banner3.png" align="middle" alt="Slideshow Image 2" />
                    <img src="images/banner/banner3.png" align="middle" alt="Slideshow Image 3" />
                </div>
      <div class="clr"></div>
      <!-- end #slideshow -->

  </div>

Style:
.header_blog { padding:0; background:#ab334b; margin:0 auto; }
0
Comment
Question by:rflorencio
[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
10 Comments
 
LVL 17

Expert Comment

by:mreuring
ID: 33699852
#slideshow {
text-align: center;
}

provided the positioning of the images is not altered they are treated as inline-block, which is similar to plain text. As such, text-align should affect them :)

A pointer concerning 'margin: 0 auto', this only works on elements that have a defined width, otherwise the browser cannot calculate how much 'space' exists outside the element...
0
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 33699865
you meant vertically alignment or horizontal?

this will give you vertical alignment
.header_blog { padding:0; background:#ab334b; margin:0 auto; height:300px;}
img.active { margin-top:100px; margin-bottom:100px; }

<div class="header_blog">
                <div id="slideshow">
                    <img src="images/banner/banner1.png" height="100px" alt="Slideshow Image 1" class="active"/>
                    <img src="images/Banner/banner3.png" height="100px" alt="Slideshow Image 2" />
                    <img src="images/banner/banner3.png" height="100px" alt="Slideshow Image 3" />
                </div>
      <div class="clr"></div>
  </div>

0
 

Author Comment

by:rflorencio
ID: 33699923
Horizontal alignment.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 33700024
check this one
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<style>
			#slideshow { background:#ab334b; min-width:300px; padding: 10px 60px; display:inline; min-height:80px;}
		</style>
	</HEAD>

	<BODY BGCOLOR="#FFFFFF">
			<div id="slideshow">
                    <img src="21072010.jpg" width="60px" height="60px" alt="Slideshow Image 1"/>
                    <img src="18072010.jpg" width="60px" height="60px" alt="Slideshow Image 2"/>
                    <img src="21022009.jpg" width="60px" height="60px" alt="Slideshow Image 3"/>
            </div>
	</BODY>
</HTML>

Open in new window

0
 
LVL 4

Expert Comment

by:acashok
ID: 33700113
please try with this:

<div class="header_blog" align="center">
      <!-- * * * Banner -->
         
                <div id="slideshow" align="center">
                    <img src="images/banner/banner1.png" align="middle" alt="Slideshow Image 1" class="active"/>
                    <img src="images/Banner/banner3.png" align="middle" alt="Slideshow Image 2" />
                    <img src="images/banner/banner3.png" align="middle" alt="Slideshow Image 3" />
                </div>
      <div class="clr"></div>
      <!-- end #slideshow -->

  </div>
0
 

Author Comment

by:rflorencio
ID: 33700222
none of the solutions work
0
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 33700474
It worked for me in IE8, FF2, Chrome6, and safari4
See this pic (from IE8)
let me know which browser you are using

abc.png
0
 

Author Comment

by:rflorencio
ID: 33700848
The images are centered, but are not centered in the middle of the browser page.
0
 
LVL 40

Accepted Solution

by:
Gurvinder Pal Singh earned 2000 total points
ID: 33701070
check this then

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<style>
			html, body, div#wrapper
			{
				width:100%;
			}
			#slideshow 
			{ 
				position:absolute;
				background:#ab334b; 
				width:60%; 
				display:inline-block; 
				min-height:80px !important; 
				margin-left:20%;
				margin-right:20%;
			}
		</style>
	</HEAD>

	<BODY BGCOLOR="#FFFFFF">
		<div id="wrapper">
			<div id="slideshow">
                    <img src="21072010.jpg" width="33%" height="60px" alt="Slideshow Image 1"/>
                    <img src="18072010.jpg" width="32%" height="60px" alt="Slideshow Image 2"/>
                    <img src="21022009.jpg" width="33%" height="60px" alt="Slideshow Image 3"/>
            </div>
		</div>
	</BODY>
</HTML>

Open in new window

0
 

Author Closing Comment

by:rflorencio
ID: 33702605
work
0

Featured Post

Independent Software Vendors: 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

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
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).

650 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