We would like to know how to center div and a float right div.
<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.center {<!--from w w w. j ava 2s .c o m-->
border-style: solid;
border-width: 1px;
background-color: #EEE;
width: 650px;
height: 200px;
margin: 0 auto;
display: block;
position: relative;
}
.right {
border-style: solid;
border-width: 1px;
background-color: #CCC;
width: 200px;
height: 200px;
float: right;
display: block;
}
body {
border-style: dashed;
border-width: 1px;
}
</style>
</head>
<body>
<div class="right">right</div>
<div class="center">center</div>
</body>
</html>
The code above is rendered as follows: