css - Using flex to center and stretch background -
How do I focus this smiley on horizontally and vertically at the top of the image while 50% of its size container?
Like:
.test {display: flex; } .test .smile {background-image: url (https://rawgit.com/anonymous/9f37047667b06af42c3d/raw/65a00b0f38b05bb6c96fa827993dbae31fe391b3/test.svg); Repeat Background: No Repetition; Justification: center; Alignment-material: center; Flex-direction: column; Height: 50%; Width: 50%; } & lt; Div class = "test" & gt; & Lt; A & gt; & Lt; Img src = "http://lorempixel.com/400/400" & gt; & Lt; Span class = "smile" & gt; & Lt; / Span & gt; & Lt; / A & gt; & Lt; / Div & gt;
Container height set But I'm only able to work Flexbox . Since your aligned image is set as a background image, there is no easy way to set the width and height. If it was an image, you would be able to easily widen 50% and the height will take care of yourself.
.test {display: flex; Alignment-item: center; Justification: center; Height: 400 pixels; Width: 400px; Background: URL (http://lorempixel.com/400/400) no-repeat; } .test .smile {background-image: url (https://rawgit.com/anonymous/9f37047667b06af42c3d/raw/65a00b0f38b05bb6c96fa827993dbae31fe391b3/test.svg); Repeat Background: No Repetition; Display area; Width: 100px; Height: 100 pixels; } If you are using svg, you only need to set the height of the .mile square. .
Comments
Post a Comment