Effect How to - Create image border








Question

We would like to know how to create image border.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.content {<!--   w ww  .j av a2 s.  c o  m-->
  width: 100px;
  float: left;
}

.menu_books .center {
  width: 80px;
  height: 30px;
  padding: 10px;
  text-align: center;
  background-color: #EEE;
  float: left;
}

.menu_books .middle {
  width: 80px;
  height: 10px;
  background: url(http://www.java2s.com/style/download.png);
  float: left;
  line-height: 0;
  font-size: 0
}

.menu_books .corner {
  width: 10px;
  height: 10px;
  float: left;
  line-height: 0;
  font-size: 0
}

.menu_books .top-left {
  background: url(http://www.java2s.com/style/download.png);
}

.menu_books .top-right {
  background: url(http://www.java2s.com/style/download.png);
}

.menu_books .bottom-left {
  background: url(http://www.java2s.com/style/download.png);
}

.menu_books .bottom-right {
  background: url(http://www.java2s.com/style/download.png);
}
</style>
</head>
<body>
  <div class="content menu_books">
    <span class="corner top-left"></span> 
    <span class="middle"></span> 
    <span class="corner top-right"></span>
    <div class="center">Main</div>
    <span class="corner bottom-left"></span> 
    <span class="middle"></span>
    <span class="corner bottom-right"></span>
  </div>
</body>
</html>

The code above is rendered as follows: