how can i do box like facebook timeline - css

I'm trying to create a timeline similar to Facebook's timeline, i.e. I want a timeline with two columns where I can place elements on the left and on the right.
In order to do so, I started with the following code but it does not work as expected:
<ol class="timeline2 clear">
<li class="spine">
</li>
<?php
$counter=0;
foreach ($response as $row) {
if($counter % 2 == 0){$class= "right";} else $class="left";
?>
<li class="<?=$class ?>">
<i class="pointer"></i>
<div class="unit">
<!-- Story -->
<div class="storyUnit">
<div class="imageUnit">
<? if (empty($row->pic)) { ?>
<img width="32" height="32" alt="" src="images/nopic.png">
<? } else { ?>
<img width="32" height="32" alt="" src="uploads/<?php echo $row->pic; ?>">
<? } ?>
<div class="imageUnit-content">
<h4><?php echo $row->fullname; ?></h4>
<p><?php echo $row->ev_date ?></p>
</div>
</div>
<p><?php echo $row->ev_text; ?></p>
<? if (!empty($row->ev_pic)) { ?>
<p><img src="uploads/<?php echo $row->ev_pic ?>" width="250" height="250"</p>
<? } ?>
</div>
<!-- / Story -->
<!-- Units -->
<ol class="storyActions">
<!-- / Comment -->
</ol>
<!-- / Units -->
</div>
</li>
<?php $counter++; } ?>
<div class="clear"></div>
</ol>
<? } ?>
the css of this box like :-
.timeline2 {
background: url("../images/line.png") repeat-y scroll center top transparent;
list-style: none outside none;
margin: 0;
padding: 6px;
position: relative;
height:auto;
}
.timeline2 > li {
clear: left;
float: left;
margin-bottom: 15px;
position: relative;
width: 326px;
z-index: 2;
}
.timeline2 > .right {
clear: right;
float: right;
}
.timeline2 .pointer {
background: url("../images/icons-4.png") no-repeat scroll -41px -28px transparent;
height: 15px;
position: absolute;
right: -18px;
top: 20px;
width: 19px;
}
.timeline2 .right > .pointer {
background-position: -61px -28px;
left: -18px;
right: auto;
}
.timeline2 > .left + .right > .pointer {
top: 40px;
}
.timeline2 > .right + li > .pointer {
top: 40px;
}
.timeline2 .highlight {
clear: both;
float: none;
width: auto;
}
.timeline2 .spine {
height: 100%;
left: 436px;
position: absolute;
width: 29px;
z-index: 1;
}
.timeline2 .spine > a, .timeline2 .spine a:visited {
display: block;
height: 100%;
}
.unit {
background: none repeat scroll 0 0 #FFFFFF;
border: 1px solid #C4CDE0;
border-radius: 3px 3px 3px 3px;
padding: 5px;
}
.storyUnit {
padding: 10px;
}
.imageUnit {
border-bottom: 1px solid #CCCCCC;
font-size: 11px;
margin-bottom: 15px;
padding-bottom: 5px;
}
.imageUnit .imageUnit-content {
display: inline-block;
padding-left: 5px;
vertical-align: top;
}
.imageUnit .imageUnit-content > p {
margin: 0;
}
.imageUnit .imageUnit-content a{
display: inline-block;
padding-left: 5px;
vertical-align: top;
color: #3589CF;
}
.photoUnit {
margin: 0 -10px -5px;
}
.controls {
background: none repeat scroll 0 0 #F2F2F2;
border-top: 1px solid #E6E6E6;
list-style: none outside none;
margin: 5px -5px -5px;
padding: 4px;
}
.controls > li {
display: inline-block;
}
.controls .post {
float: right;
}
.actions {
font-size: 11px;
font-weight: bold;
list-style: none outside none;
margin: 0;
overflow: hidden;
padding: 0;
}
.actions > li {
border-left: 1px solid #E5E5E5;
display: inline;
float: left;
}
.actions > li:first-child {
border-left: medium none;
}
.actions > li > a {
display: inline-block;
margin: 0 3px;
padding: 5px;
}
.actions > li > a:hover {
background: none repeat scroll 0 0 #EBEEF4;
text-decoration: none;
}
.actions .active > a {
color: #000000;
}
.storyActions {
background: none repeat scroll 0 0 #EDEFF4;
font-size: 11px;
list-style: none outside none;
margin: 0;
padding: 5px 10px;
}
.storyActions > li {
display: inline;
}
.storyActions > li:before {
content: " ยท ";
}
.storyActions > li:first-child:before {
content: "";
}
#Spinner {
padding: 10px 0;
text-align: center;
}
when the left box is big than right, and there are another left box, the right box not show behind left box, there are below left box.
how can i show it behind left box
see :- http://jsfiddle.net/RuVqu/

You need to use a dynamic grid layout. It works by placing elements in optimal position based on available vertical space.

Related

How to fix this navigation menu - It wont show up

You can check webpage on http://prodenvermovers.wpupkeep.org
After I hover on Services page it wont show up dropdown menu.
The dropdown was made in wordpress via wp_nav_menu. I have 5 pages and one of them is Services page with a dropdown with 3 pages. I`m also using wp_bootstrap_navwalker
I have tried a lot of stuff. Firstly I changed some data in wp_bootstrap_navwalker
$atts['href'] = 'http://prodenvermovers.wpupkeep.org/services/';
$atts['data-hover'] = 'dropdown';
I removed absolute class from boostrap responsive and it show up but like this
Check the picture --> http://prntscr.com/oh5lzk
As you can see on this picture it pushed my logo and free estimate with dropdown.
header.php
/**
* The header for our theme
*
* This is the template that displays all of the <head> section and everything up until <div id="content">
*
* #link https://developer.wordpress.org/themes/basics/template-files/#template-partials
*
* #package crosscountry
*/
?>
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="https://gmpg.org/xfn/11">
<?php wp_head(); ?>
</head>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-76356877-1', 'auto');
ga('send', 'pageview');
</script>
<body <?php body_class(); ?>>
<div id="page" class="site">
<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'crosscountry' ); ?></a>
<!-- header parts -->
<header id="masterhead" class="site-header">
<div class="md-wrapper">
<div class="container">
<nav class="navbar navbar-expand-lg navbar-light">
<a class="country-logo" href="<?php echo site_url() ?>">
<img class="country-logo-style" src="<?php echo get_bloginfo("template_directory"); ?>/images/header/logo_pdm.png" alt="Pro Denver Movers Logo" ></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="col-md-12 col-lg-7 padding-nav-left">
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<?php
wp_nav_menu( array(
'menu' => 'header_menu_1 ',
'depth' => 3,
'container' => false,
'menu_class' => 'nav navbar-nav',
'fallback_cb' => 'wp_page_menu',
//Process nav menu using our custom nav walker
'walker' => new wp_bootstrap_navwalker())
);
?>
</div>
</div>
<div class="col-md-3 md-header-cta-class">
<a class="md-header-estimate" href="<?php echo site_url('free-estimate') ?>">Free Estimate</a>
</div>
</nav>
</div>
</div>
</div>
</header>
<div id="content" class="site-content">
md-header.css
background: transparent;
float: left;
width: 100%;
z-index: 2;
overflow: hidden;
border-bottom: 1px solid rgb(194, 194, 194);
}
header#masterhead .container {
background: transparent;
}
.site-title,
.site-description {
display: none;
}
.country-logo {
margin: 0;
}
.country-logo-style {
width: 193px;
height: 60px;
}
.menu-navigation {
margin-top: 5px;
}
/* STYLING UL ELEMENTS */
.navbar {
padding: 0 !important;
}
.navbar-nav {
color: #333333;
margin-left: 100px;
text-transform: uppercase;
margin: 0;
}
.nav-item {
padding-left: 0px;
padding-right: 0px;
font-weight: 600;
}
.site-header {
overflow: hidden;
}
a.nav-link {
padding-bottom: 25px !important;
padding-top: 25px !important;
border-bottom: 4px solid transparent;
width: 100px;
font-size: 16px;
color: #fff !important;
transition: all 0.5s ease-in;
}
.site-header .nav-link:hover {
border-bottom: 4px solid #ecf014 ;
color: rgb(235, 235, 235) !important;
}
#media screen and (max-width: 1255px) {
.nav-item {
padding-left: 10px;
}
.nav .navbar-nav li a {
font-size: 14px;
}
}
nav .navbar-nav li a:hover {
color: #0082ff !important;
}
.site-header .navbar .navbar-collapse li > a {
padding: 30px 0 !important;
margin-left: auto;
margin-right: auto;
text-align: center;
max-width: 100%;
}
a.md-header-estimate {
font-size: 18px;
letter-spacing: 0px;
border-radius: 5px;
background: #b4b4b4;
opacity: 1;
font-weight: 500;
padding: 14px 42px;
color: white;
}
.md-header-cta-class {
text-align: right;
}
.fa {
position: absolute;
cursor: pointer;
transition: background 2s;
}
.fa:hover {
background: #dcf7ff;
border-radius: 5px;
}
.padding-nav-left {
padding-left: 70px;
}
.dropdown-menu a.dropdown-item {
font-size: 14px;
font-weight: bold;
padding-top: 5px !important;
padding-bottom: 5px !important;
}
.nav-item .dropdown-menu li {
padding-left: 25px !important;
padding-right: 15px !important;
}
.fa-chevron-down:before {
line-height: 25px;
margin-left: 5px;
}
.dropdown-menu {
position: absolute;
top: 100%;
left: 0;
margin: -1px 0 0 0;
}
.wrapper .navbar .dropdown.dropdown-menu {
display: none;
margin: 0;
height: 100%;
min-width: 220px;
text-align: left;
background: #fff;
padding: 20px 0;
box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.4);
color: #16345e;
position: absolute;
z-index: 99999;
}
.wrapper .navbar .dropdown:hover .dropdown-menu {
display: block;
}
.dropdown-toggle:after {
content: "\f063";
font-size: 15px;
visibility: visible;
padding-left: 5px;
font-family: fontawesome;
}
.site-header .navbar .navbar-nav .active > a {
border-bottom: 4px solid #ecf014 ;
}
#media screen and (max-width: 1400px) {
.navbar-nav > li > a {
font-size: 14px !important;
}
a.vk-header-phone {
font-size: 16px;
}
}
#media screen and (max-width: 1650px) {
.vk-header-cta-class {
text-align: right;
}
}
#media screen and (min-width: 991px) and (max-width: 1200px) {
.site-header .navbar .navbar-collapse li {
padding-left: 0 !important;
}
.padding-nav-left {
padding-left: 20px !important;
}
}
#media screen and (max-width: 991px) {
.navbar-collapse {
padding: 0;
}
button.navbar-toggler {
float: right;
}
a.md-header-estimate {
display: none;
}
.padding-nav-left {
padding-left: 15px;
}
.site-header .navbar .navbar-collapse li a {
padding-top: 10px !important;
padding-bottom: 10px !important;
}
}
#media screen and (max-width: 500px) {
.country-logo-style {
width: auto;
height: auto;
}
}
Its maybe because of bootstrap classes col-md-7 and col-md-5 inside of header? I dont know.
Help guys. I need to finish this until monday for my conmpany
Remove overflow:hidden from #masterhead and from .siteheader
Remove background-clip from .dropdown-menu

Div height affecting adjcent item in the same row

I have styling problem where my avatar image height will affect other inline items next to it. The image below is to illustrate the problem.
So if you see when I make my avatar logo taller it'll bring down the navigation links.
I want my avatar image not to affect the links next to it.
Here's my css and html:
.terms-link {
display: inline-flex;
align-items: center;
margin-right: -9px;
}
.user {
width: 153px;
}
.terms {
width: 103px;
}
.dropdown {
position: absolute;
right: 0;
padding: 30px 50px 30px 0;
background-color: #336F9C;
margin-top: 17px;
z-index: 10;
}
.right-side {
display: flex;
align-items: center;
}
.sign-up {
display: inline;
color: white;
margin-left: 1rem;
margin-right: 1rem;
}
.sign-up a {
padding: 5px;
}
nav a.is-active {
border-bottom: 3px solid #00aedb;
}
nav a.is-active.transparent {
border-bottom: 0;
color: #00aedb !important;
}
nav {
margin-bottom: 0;
}
nav a {
padding: 0 1.5rem 17px 1.5rem;
position: relative;
color: white;
text-decoration: none;
font-size: medium;
}
.explore-beta span {
font-size: x-small;
font-style: italic;
}
.spacer {
display: inline;
font-size: medium;
padding: 0 1rem 17px 1rem;
color: white;
}
.avatar-frame{border: 1.5px solid #c7b89e;}
.avatar-frame,.avatar-frame img{
width:30px;
height: 30px;
-webkit-border-radius: 50%; /* Saf3+, Chrome */
border-radius: 50%; /* Opera 10.5, IE 9 */
/*-moz-border-radius: 50%; Disabled for FF1+ */
}
<div class="right-side">
<nav>
<a routerLink="/initiatives" routerLinkActive="is-active">Initiatives</a>
<a routerLink="/search" routerLinkActive="is-active">Summary</a>
<a routerLink="/clinical" routerLinkActive="is-active">Clinical Filtering</a>
<a routerLink="/explore" routerLinkActive="is-active">Explore</a>
<a routerLink="/beacon" routerLinkActive="is-active">Beacon</a>
<a routerLink="/about" routerLinkActive="is-active">About</a>
<a *ngIf="!auth.authenticated()" class="sign-up">
<a (click)="auth.login()">Log in</a>
<div class="spacer">|</div>
<a (click)="openSignUpDialog()">Sign up</a>
</a>
<a *ngIf="auth.authenticated()" [ngClass]="{'is-active': termsLinkActive}" (click)="toggleUser($event)" class="avatar-link">
<span class="terms-link">
<div class="avatar-frame">
<img [src]="userPicture" />
</div>
</span>
<div *ngIf="userDropdown" [ngClass]="['user', 'dropdown']" (click)="auth.logout()">
<a>Log out</a>
</div>
</a>
</nav>
</div>
You can use position:absolute on your avatar-link class to remove it out of the default document flow and set its parent i.e. nav to position:relative;
This will ensure avatars dimensions do not effect its siblings.
div{
border: 1px solid black;
}
nav {
position: relative;
}
.avatar-link {
position: absolute;
border: 1px solid red;
right: 20px;
top: 50%;
transform: translateY(-50%);
}
.terms-link {
display: inline-flex;
align-items: center;
margin-right: -9px;
}
.user {
width: 153px;
}
.terms {
width: 103px;
}
.dropdown {
position: absolute;
right: 0;
padding: 30px 50px 30px 0;
background-color: #336F9C;
margin-top: 17px;
z-index: 10;
}
.right-side {
display: flex;
align-items: center;
}
.sign-up {
display: inline;
color: white;
margin-left: 1rem;
margin-right: 1rem;
}
.sign-up a {
padding: 5px;
}
nav a.is-active {
border-bottom: 3px solid #00aedb;
}
nav a.is-active.transparent {
border-bottom: 0;
color: #00aedb !important;
}
nav {
margin-bottom: 0;
}
nav a {
padding: 0 1.5rem 17px 1.5rem;
position: relative;
color: white;
text-decoration: none;
font-size: medium;
}
.explore-beta span {
font-size: x-small;
font-style: italic;
}
.spacer {
display: inline;
font-size: medium;
padding: 0 1rem 17px 1rem;
color: white;
}
.avatar-frame {
border: 1.5px solid #c7b89e;
}
.avatar-frame,
.avatar-frame img {
width: 30px;
height: 30px;
-webkit-border-radius: 50%;
/* Saf3+, Chrome */
border-radius: 50%;
/* Opera 10.5, IE 9 */
/*-moz-border-radius: 50%; Disabled for FF1+ */
}
<div class="right-side">
<nav>
<a routerLink="/initiatives" routerLinkActive="is-active">Initiatives</a>
<a routerLink="/search" routerLinkActive="is-active">Summary</a>
<a routerLink="/clinical" routerLinkActive="is-active">Clinical Filtering</a>
<a routerLink="/explore" routerLinkActive="is-active">Explore</a>
<a routerLink="/beacon" routerLinkActive="is-active">Beacon</a>
<a routerLink="/about" routerLinkActive="is-active">About</a>
<a *ngIf="!auth.authenticated()" class="sign-up">
<a (click)="auth.login()">Log in</a>
<div class="spacer">|</div>
<a (click)="openSignUpDialog()">Sign up</a>
</a>
<a *ngIf="auth.authenticated()" [ngClass]="{'is-active': termsLinkActive}" (click)="toggleUser($event)" class="avatar-link">
<span class="terms-link">
<div class="avatar-frame">
<img [src]="userPicture" />
</div>
</span>
<div *ngIf="userDropdown" [ngClass]="['user', 'dropdown']" (click)="auth.logout()">
<a>Log out</a>
</div>
</a>
</nav>
</div>

Why doesn't menu on drop down appear over content?

I've got a drop down menu that won't appear over the rest of the content. I've set the position to absolute and the z-index to 99 and no luck. Any ideas how to get it to lay on top of the rest of the site?
<body>
<header>
<div class="container">
<h1 class="logo">Relaxr</h1>
<nav>
</span>
<ul>
<li>Home</li>
<li>About</li>
<li>Contact</li>
<li>Blog</li>
</ul>
</nav>
</div>
</header>
<section id="main">
<div class="container">
nav {
position: relative;
}
nav ul {
display: none;
}
header {
margin-left: -20px;
margin-right: -20px;
}
body {
margin-left: 20px;
margin-right: 20px;
}
.container {
width: 100%;
margin: 0;
}
#main {
margin-top: 10px;
}
header nav ul li {
display: block;
margin-right: 20px;
margin: 0 20px 0 0;
}
.hamburger {
margin-top: 5px;
margin-right: 80px;
margin-bottom: 20px;
float:right;
position: relative;
display: inline-block;
width: 1.5em;
height: 0.74em;
border-top: 0.2em solid #fff;
border-bottom: 0.2em solid #fff;
}
.hamburger:before {
content: "";
position: absolute;
top: 0.9em;
left: 0px;
width: 100%;
border-top: 0.2em solid #fff;
}
nav ul {
position: absolute;
left: 0; top: 100%;
width: 100%;
background-color: black;
z-index: 99;
Codepen:
http://codepen.io/kiddigit/pen/wWvPJm
In your #media query change
nav {
position: relative;
}
to
nav {
position: absolute;
}
This will keep your menu on top.
I think You should use something like this to work
$(".hamburger").click(function(e){
$("nav > ul").toggle();
});
there is only one difference I've added a closing bracket in
$("nav > ul").toggle();

Child list disappears when hovered over it

I have a Horizontal Menu. When the mouse is hovered over the child elements it disappears. The child elements cannot be clicked. I would like the child elements to stay when the mouse is hovered over it.
.header {
color: #FFFFFF;
height: 60px;
width: 100%;
margin: auto;
}
.header_logo {
width: 40%;
height: 100%;
float: left;
}
#logo {
height: 100%;
top: 0;
left: 0;
width: 50%;
}
.header_title {
width: 60%;
float: left;
}
#titles {
position: absolute;
top: 20px;
font-family: "Times New Roman", Times, serif, Georgia;
font-size: 97%;
color: #B8B8B8;
}
ul {
list-style-type: none;
}
li {
display: inline-block;
}
a {
text-decoration: none;
color: inherit;
padding: 21px 10px;
}
li a:hover {
background-color: #666699;
}
ul li ul {
display: none;
}
ul li:hover ul {
display: block;
position: absolute;
width: 100%;
top: 70px;
left: 0;
white-space: nowrap;
}
* {
border: 0;
margin: 0;
padding: 0;
}
.content {
height: 800px;
margin: auto;
background-color: #C0C0C0;
}
.footer {
margin: auto;
background-color: #000000;
}
<div class="header">
<div class="header_logo">
<img id="logo" src="civic-logo.jpg">
</div>
<div class="header_title">
<div id="titles">
<ul>
<li>PRODUCTS
<ul>
<li>CEMENT</li>
<li>STEEL</li>
<li>BRICKS</li>
<li>SAND</li>
</ul>
</li>
<li>CONTACT US </li>
</ul>
</div>
</div>
</div>
<div class="content">
</div>
<div class="footer">
</div>
It's because you have positioned your submenu absolutely, and it's too far away from your parent li, so your mouse is leaving the parent menu before it reaches the submenu. I've added borders to show you.
.header {
color: #FFFFFF;
height: 60px;
width: 100%;
margin: auto;
}
.header_logo {
width: 40%;
height: 100%;
float: left;
}
#logo {
height: 100%;
top: 0;
left: 0;
width: 50%;
}
.header_title {
width: 60%;
float: left;
}
#titles {
position: absolute;
top: 20px;
font-family: "Times New Roman", Times, serif, Georgia;
font-size: 97%;
color: #B8B8B8;
}
ul {
list-style-type: none;
}
li {
display: inline-block;
border: 1px solid blue;
}
a {
text-decoration: none;
color: inherit;
padding: 21px 10px;
}
li a:hover {
background-color: #666699;
}
ul li ul {
display: none;
}
ul li:hover ul {
display: block;
position: absolute;
width: 100%;
top: 70px;
left: 0;
white-space: nowrap;
}
* {
border: 0;
margin: 0;
padding: 0;
}
.content {
height: 800px;
margin: auto;
background-color: #C0C0C0;
}
.footer {
margin: auto;
background-color: #000000;
}
<div class="header">
<div class="header_logo">
<img id="logo" src="civic-logo.jpg">
</div>
<div class="header_title">
<div id="titles">
<ul>
<li>PRODUCTS
<ul>
<li>CEMENT</li>
<li>STEEL</li>
<li>BRICKS</li>
<li>SAND</li>
</ul>
</li>
<li>CONTACT US </li>
</ul>
</div>
</div>
</div>
<div class="content">
</div>
<div class="footer">
</div>
You have padding, but it's on your a element, and needs to be on your li element, instead. Either add padding-top to your submenu li elements or adjust their top position so that they're directly underneath (aka "touching") the parent element.
Here is the code with the menu moved to top: 40px and the padding added to the submenu li elements:
.header {
color: #FFFFFF;
height: 60px;
width: 100%;
margin: auto;
}
.header_logo {
width: 40%;
height: 100%;
float: left;
}
#logo {
height: 100%;
top: 0;
left: 0;
width: 50%;
}
.header_title {
width: 60%;
float: left;
}
#titles {
position: absolute;
top: 20px;
font-family: "Times New Roman", Times, serif, Georgia;
font-size: 97%;
color: #B8B8B8;
}
ul {
list-style-type: none;
}
li {
display: inline-block;
}
a {
text-decoration: none;
color: inherit;
padding: 21px 10px;
}
li ul li {
padding: 21px 10px;
}
li a:hover {
background-color: #666699;
}
ul li ul {
display: none;
}
ul li:hover ul {
display: block;
position: absolute;
width: 100%;
top: 40px;
left: 0;
white-space: nowrap;
}
* {
border: 0;
margin: 0;
padding: 0;
}
.content {
height: 800px;
margin: auto;
background-color: #C0C0C0;
}
.footer {
margin: auto;
background-color: #000000;
}
<div class="header">
<div class="header_logo">
<img id="logo" src="civic-logo.jpg">
</div>
<div class="header_title">
<div id="titles">
<ul>
<li>PRODUCTS
<ul>
<li>CEMENT</li>
<li>STEEL</li>
<li>BRICKS</li>
<li>SAND</li>
</ul>
</li>
<li>CONTACT US </li>
</ul>
</div>
</div>
</div>
<div class="content">
</div>
<div class="footer">
</div>

image grid flow outside the contentwrap

I'm creating an image grid. it works fine outside contentwrap but when in contenwrap all the images flow outside the contentwrap. whats wrong with my code? I'm facing one more problem is image caption. I'm unable to add caption to images.
#contentwrap {
width: 850px;
float: left;
margin: 0 auto;
}
#content {
background: #FFFFFF;
border-radius: 10px;
border: 1px solid #ebebeb;
margin: 5px;
}
ul#grid {
list-style: none;
margin: 0 0 0;
width: 550px;
}
#grid li {
float: left;
margin: 0 0 10px 5px;
}
.portfolio {
padding: 0px;
margin-left: 0; margin-right: 0; margin-top:0;
width: 513px;
font-family: arial, serif;
text-align: center;
}
#grid li a:hover img {
opacity:0.3; filter:alpha(opacity=30);
}
#grid li img {
background-color: white;
padding: 7px; margin: 0;
border: 1px dotted #58595b;
width: 120px;
height: 98px;
}
#grid li a {
display: block;
}
HTML:
<div id="contentwrap">
<div id="content">
<div class="portfolio">
<ul id="grid">
<li><img src="image.jpg"></li>
<li><img src="image.jpg"></li>
<li><img src="image.jpg"></li>
</ul>
</div>
</div>
</div>
Here is working
JsFiddle
simple add
height:auto;
overflow:auto;
to class = MyBox

Resources