1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Styled-componentsで背景画像を使う際のメモ

Posted at

背景

Propsを受け取って背景画像をするときに
どうすんだ!?と思い調べていると
ついつい毎回覚えないのでメモ

結論


//typescriptバージョン

interface IBgImageProps {
	bgImage?: string;
}



const Content = styled.div<IBgImageProps>`
    background-image: url(${props => props.bgImage});
`;


//通常


const Content = styled.div`
    background-image: url(${props => props.bgImage});
`;


//jsx側

import {bg} from "assets/image";

<StyledBg bgImage={bg}>
  テキストテキスト
<StyledBg>
	

まとめ

色々とできるが
ついつい忘れがち。。。

とはいえ
色々とできるので、忘れそうになったらメモしていこう

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?