Remove the width from your #inner
div and set a margin on the right of it that is the full width ( margin + padding + width + etc. ) of your figure
. The figure
will float into the right margin of #inner
. Since DIVs are block level elements they take up 100% width by default.
CSS
#fig {
width: 162px;
height: 277px;
float: right;
margin: auto 7px;
}
#inner {
text-align: center;
padding: 1% 5%;
margin-right: 176px;
background-color: red; /* demonstration only */
}
img {
width: 162px;
height: 277px;
}