javascript - React js css class background image not visible -


i have added class in react component.
css file:

.bg{    background: url('../img/bg.jpg');    border: 2px solid black; } 

react render method:

  render() {    return (     <div>       <div classname="bg">        hey       </div>     </div>   ); } 

the browser shows border , loads image image not visible.

the screenshot follows: enter image description here

can tell me doing wrong?

this happening because div.bg not have height specified. because of this, height fits text content exactly.

background images of size have no affect on sizing of parent element. if goal able see entire image, need specify height div.bg matches height of original image.


Comments

Popular posts from this blog

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -