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.
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
Post a Comment