HTML image and div resize -


.d1 {     background-color: red;     text-align: center; }  <div class="d1">     <img src="http://www.aliceseelywholesale.net/wp-content/uploads/adb101-daisy-cutout-narrow-link-bracelet-300x100.jpg"> </div> 

i use above simple code display image in middle div. code works when resize window below width of image, border/div doesn't cover image... there way fix this? ty

enter image description here

if want use backgound image <div> suggest set image background-image div, , remove <img> element.

this save using addition element , fix problem:

.d1 {      width:300px;      height:100px;      background-color: red;      text-align: center;      background-image: url(http://www.aliceseelywholesale.net/wp-content/uploads/adb101-daisy-cutout-narrow-link-bracelet-300x100.jpg);      background-size:cover;  }
<div class="d1">      </div>


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -