SitePoint Sponsor

User Tag List

Results 1 to 22 of 22

Threaded View

  1. #1
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,603
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)

    vertical centering

    I've tried various techniques to get vertical centering to work in this situation, but have been unsuccessful.

    I whipped up a silder/rotator/carousel for content. It has the option of display just text, just a thumbnail image, or both.

    What I'm trying to get vertically centered is the image when both the text and thumbnail image are displayed (the example is inside element ID "post-87").

    The image height can vary between 1px and 200px.

    Code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <script src="http://code.jquery.com/jquery-1.8.1.min.js" type="text/javascript"></script>
    <script src="http://malsup.github.com/jquery.cycle.all.js" type="text/javascript"></script>
    <style type="text/css">
    /* start reset */
    body, div, span, h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, button, p, blockquote, table, th, td { margin:0px; padding:0px; }
    body {
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    	font-size: 100.01%;
    	color: black;
    	background-color: #f9f9f9;
    }
    p { margin: .2em 0 .8em 0; }
    ul, ol, li { margin: 0 0 0 1.4em; padding: 0px; }
    ul, ol { margin-top: .2em; margin-bottom: .8em; }
    
    
    a img { border: none; }
    
    
    
    
    /* --clearfix hack-- */
    .clearfix:after {
    	content:" ";
    	display:block;
    	height:0;
    	clear:both;
    	visibility:hidden;
    }
    .clearfix { display:inline-block; }
    
    
    /* mac hide \*/
    * html .clearfix {height: 1%;}
    .clearfix {display: block;}
    /* End hide */
    /* --end clearfix hack-- */
    
    
    /* end reset */
    
    
    
    
    #content {
    	width: 960px;
    	margin: 20px auto;
    }
    
    
    
    
    /* start carousel */
    #content #featured-carousel {
    	position:relative;
    	width:100%;
    	border:1px solid #CAD6E8;
    	-webkit-border-radius: 6px;
    	-moz-border-radius: 6px;
    	border-radius: 6px;
    	margin-bottom:2em;
    }
    #content #featured-carousel ul {
    	position:relative;
    	margin:0;
    	float:left;
    	width:100%;
    }	
    #content #featured-carousel ul li {
    	margin:0;
    	padding:0;
    	list-style:none;
    	clear:both;
    	position:absolute;
    	width:100%;
    	/*border:1px solid black;*/ /* outline for troubleshooting */
    	overflow:hidden;
    	height: auto !important;
    	min-height:100%;
    	height:100%;
    }
    #content #featured-carousel ul li div.carousel-content-left {
    	float:left;
    	width:50%;
    	/*border:1px solid blue;*/ /* outline for troubleshooting */
    }
    #content #featured-carousel ul li div.carousel-content-left-inner {
    	padding:.4em .4em .4em .8em;
    }
    #content #featured-carousel ul li div.carousel-content-right {
    	float:right;
    	width:49%;
    	text-align:center;
    	/*border:1px solid blue;*/ /* outline for troubleshooting */
    }
    /*#content #featured-carousel ul li div.carousel-content-right:before {
    	content: '';
    	display: inline-block;
    	height: 100%; 
    	vertical-align: middle;  
    }*/
    #content #featured-carousel ul li div.carousel-content-right-inner {
    	padding:.4em .8em .4em .4em;
    	/*border:1px solid black;*/ /* outline for troubleshooting */
    }
    #content #featured-carousel ul li div.carousel-content-right-inner a {
    
    
    }
    
    
    
    
    
    
    #content #featured-carousel ul li.nocontent div.carousel-content-left,#content #featured-carousel ul li.nothumb div.carousel-content-left {
    	clear:both;
    	display:block;
    	width:100%;
    }
    #content #featured-carousel ul li.nocontent div.carousel-content-right {
    	clear:both;
    	display:block;
    	width:100%;
    }
    #content #featured-carousel ul li.nocontent div.carousel-content-right-inner img {
    	margin-top:0;
    }
    
    
    
    
    #content #featured-carousel ul li.nothumb div.carousel-content-right {
    	clear:both;
    	display:none;
    	width:0;
    	float:left;
    }
    #content #featured-carousel ul li.nothumb div.carousel-content-right-inner img {
    	margin-top:0;
    }
    
    
    
    
    #content #featured-carousel #carousel-nav{
    	position:relative;
    	text-align:center;
    	padding: .5em 0 .3em 0;
    	clear:both;
    	border-top:1px solid #CAD6E8;
    	zoom:1;
    }
    
    
    #content #featured-carousel #carousel-nav-pages a{
    	display:inline-block;
    	background:#CCCCCC;
    	width:15px;
    	height:15px;
    	margin:0px 4px 2px 4px;
    	
    }
    #content #featured-carousel #carousel-nav-pages a:hover{
    	background:#00a0e4;
    }
    #content #featured-carousel #carousel-nav-pages a.activeSlide {
    	background:#00a0e4;
    }
    
    
    #content #featured-carousel a#carousel-next-link,#content #featured-carousel a#carousel-prev-link{
    	display:inline-block;
    	width:20px;
    	height:20px;
    }
    #content #featured-carousel a#carousel-next-link{
    	background:#CCCCCC;
    }
    #content #featured-carousel a#carousel-next-link:hover{
    	background:#00a0e4;
    }
    #content #featured-carousel a#carousel-prev-link{
    	background:#CCCCCC;
    }
    #content #featured-carousel a#carousel-prev-link:hover{
    	background:#00a0e4;
    }
    
    
    
    
    </style>
    
    
    
    
    </head>
    <body>
    
    
    <div id="content">
    	<div id="content-inner">
    
    
    		<!-- begin content -->
    
    
    				
    																	
    			<div id="featured-carousel">
    				<ul id="carousel-items">
    					<li class="nocontent" id="post-228">
    						<div class="carousel-content-left">
    							<div class="carousel-content-left-inner">
    								<h2 class="carousel-title"><a href="">More Plans</a></h2>
    								<div class="entry-meta"><span class="post-date">Published on September 7, 2012</span></div>
    								<div class="carousel-summary"></div>
    							</div>
    						</div>
    						<div class="carousel-content-right">
    							<div class="carousel-content-right-inner">
    								<a href=""><img width="320" height="200" alt="" class="attachment-carousel-thumb wp-post-image" src="http://www.placehold.it/320x200"></a>
    							</div>
    						</div>
    					</li>
    
    
    					<li class="" id="post-87">
    						<div class="carousel-content-left">
    							<div class="carousel-content-left-inner">
    								<h2 class="carousel-title"><a href="">Some Announcements</a></h2>
    								<div class="entry-meta"><span class="post-date">Published on August 24, 2012</span></div>
    								<div class="carousel-summary"><p>Lorem ipsum dolor sit amet. Ut enim ad minim veniam, quis ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum...<a href="">Read More&nbsp;&raquo;</a></p></div>
    							</div>
    						</div>
    						<div class="carousel-content-right">
    							<div class="carousel-content-right-inner">
    								<a href=""><img width="320" height="200" alt="" class="attachment-carousel-thumb wp-post-image" src="http://www.placehold.it/320x200"></a>
    							</div>
    						</div>
    					</li>
    
    
    					<li class="nothumb" id="post-90">
    						<div class="carousel-content-left">
    							<div class="carousel-content-left-inner">
    								<h2 class="carousel-title"><a href="">Small Plans</a></h2>
    								<div class="entry-meta"><span class="post-date">Published on August 22, 2012</span></div>
    								<div class="carousel-summary"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum... <a href="">Read More&nbsp;&raquo;</a></p></div>
    							</div>
    						</div>
    						<div class="carousel-content-right">
    							<div class="carousel-content-right-inner">
    								<a href=""><img src="http://www.placehold.it/125x97"></a>
    							</div>
    						</div>
    					</li>
    
    
    				</ul>
    				
    				<div id="carousel-nav">
    					<a title="Previous" id="carousel-prev-link" href=""></a>
    					<span id="carousel-nav-pages"></span>
    					<a title="Next" id="carousel-next-link" href=""></a>							
    				</div>
    				
    				<script type="text/javascript">
    					$('#featured-carousel ul').cycle({
    						fx:'fade',
    					speed:800,
    						timeout:5000,
    						prev: '#carousel-prev-link',
    						next: '#carousel-next-link',
    						pager: '#carousel-nav-pages',
    						pause: 1,
    						pagerAnchorBuilder: function(idx, slide) {
    							var index = idx+1;
    							return '<a href="#" title="'+index+'"></a>';
    						}
    					});
    				</script>
    		</div>
    					
    					
    					
    
    
    	<!--end content -->			
    					
    	</div>
    </div>
    			
    </body>
    </html>
    Attached is an image that shows the carousel. The carousel on the top shows how things are displayed now. The carousel on the bottom is what I'm trying to get it to look like.

    carousel.jpg
    Last edited by Force Flow; Sep 12, 2012 at 07:17. Reason: minor code update
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •