Using background image for DIV : background « CSS « HTML / CSS






Using background image for DIV

   
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
  xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
<style rel="stylesheet" type="text/css">

.current {
  background: url(image-demo-2011/current_bg.jpg) top left no-repeat;
  width: 659px;
  overflow: hidden;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
  color: #DBE0E8;
  padding: 0 0 25px 0;
}

.current p {
  display: block;
  float: left;
  width: 520px;
  padding: 22px 0 0 35px;
}

.current_link {
  display: block;
  float: left;
  margin: 15px 0 0 5px;
}

.post {
  width: 269px;
  height: 312px;
  float: left;
  background: url(image-demo-2011/post_bg.gif) top left no-repeat;
  padding: 15px 28px 0 25px;
  margin: 0 15px 11px 0;
}

.post span {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  color: #0893EF
}

.post h5 {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 18px;
  color: #3E3E3E;
  padding: 8px 0 10px 0;
}

.post p {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
  color: #6D7072;
  display: block;
  margin: 13px 0;
}

.more {
  display: block;
  margin: 0 0 0 80px;
}


</style>
</head>
<body>
        <div class="current">
          <p>Illum secundum exerci erat plaga illum, enim, venio. Tamen causa ut diam torqueo sagaciter inhibeo si quae exerci lobortis. Appellatio vel hos autem, ludus luptatum mauris ratis jugis interdico. Gilvus consequat abico demoveo lenis validus typicus ut commodo.</p>
        </div>
        <div class="post">
          <span>September 27th</span><br />
          <h5>Name Post 1</h5>
          <p>Illum secundum exerci erat plaga illum, enim, venio. Tamen causa ut diam torqueo sagaciter inhibeo si quae exerci lobortis. Appellatio vel hos autem, ludus luptatum mauris ratis jugis interdico. Gilvus consequat abico demoveo lenis validus typicus ut commodo.</p>
        </div>
        <div class="post">
          <span>September 25th</span><br />
          <h5>Name Post 2</h5>
          <p>Illum secundum exerci erat plaga illum, enim, venio. Tamen causa ut diam torqueo sagaciter inhibeo si quae exerci lobortis. Appellatio vel hos autem, ludus luptatum mauris ratis jugis interdico. Gilvus consequat abico demoveo lenis validus typicus ut commodo.</p>
        </div>
        <div class="post">
          <span>September 23th</span><br />
          <h5>Name Post 3</h5>
          <p>Illum secundum exerci erat plaga illum, enim, venio. Tamen causa ut diam torqueo sagaciter inhibeo si quae exerci lobortis. Appellatio vel hos autem, ludus luptatum mauris ratis jugis interdico. Gilvus consequat abico demoveo lenis validus typicus ut commodo.</p>
        </div>
        <div class="post">
          <span>September 20th</span><br />
          <h5>Name Post 4</h5>
          <p>Illum secundum exerci erat plaga illum, enim, venio. Tamen causa ut diam torqueo sagaciter inhibeo si quae exerci lobortis. Appellatio vel hos autem, ludus luptatum mauris ratis jugis interdico. Gilvus consequat abico demoveo lenis validus typicus ut commodo.</p>

        </div>
      </div>
</body>

</html>

   
    
    
  








Related examples in the same category

1.'background' Example
2.The background shorthand property provides for specifying all five separate background properties in one single property.
3.background: mistyrose
4.background: gray
5.background: rgb(128, 128, 128)
6.The background-color value can be transparent keyword, which is also the default value.
7.The background-color value can be a hexadecimal value
8.The background-color value can be a short hexadecimal value
9.background: yellow;
10.background: white url('http://java2s.com/style/logo.png') center center; (image and position)
11.background: url('http://java2s.com/style/logo.png') repeat-x; (background-image-repeat)
12.background: url('http://java2s.com/style/logo.png') repeat-y scroll; (background image repeat attachment)
13.background: mistyrose;
14.background: pink;
15.background: lightyellow;
16.background: rgb(234, 234, 234);
17.background: yellowgreen;
18.background: no-repeat fixed bottom center;
19.background x tiled
20.background y tiled
21.Background fixed
22.Whole page background
23.Whole page shading effect
24.HTML and CSS for background colors
25.Using more than one background image
26.Merge several image to one big background image
27.CSS Background Attributes Example
28.Link with background
29.hr border: none; background-color: #256579; color: #256579; height: 2px; width: 80%;
30.tfoot td background: #808080;color: white;
31.background attachment: fixed
32.option background-color: #3CB371;color: #ffffff;
33.code padding:3px; background-color:black; color:#FFFFFF;
34.background-attachment: fixed;
35.demonstrating the background-color property
36.Background grid
37.a:hover {color:#FF9900; text-decoration:underline; background-color:#f9f0f0;}
38.thead, tfoot {border:solid; background-color:#efefef; font-size:36px;}
39.Update background image when mouse hover
40.background: url(img/document.gif) no-repeat left center;
41.Change background when mouse hover
42.a:hover background: inherit;
43.Using shade image to as the title bar background
44.Round corner with background image
45.Shading background
46.Blue background
47.Black background
48.background: #ffffff url(1024px-images/background.gif) top center repeat-y;
49.Round corner with background image 2
50.Block quote with background
51.background: rgb(244, 244, 244);
52.The background shorthand property
53.background assigns the padding area inside the box to a background color and/or image.
54.Set URL for Background Image
55.Background with no repeat
56.Add background image to LI
57.background: lightblue
58.background: lightgreen
59.background: pink
60.Css Rollover with image