私は自分のカートのアイコンの上に座っているカートの中のアイテムの数を含むバッジを作成しようとしています。私のバッジはなぜ楕円ですか?
何らかの理由でバッジが円の代わりに楕円形になっています。私は間違って何をしていますか?
const cartStyle = {
width: "48px",
height: "48px",
verticalAlign: "middle",
float: "right",
marginBottom: "0",
backgroundImage: `url(${ShoppingCart})`
};
const badgeStyle = {
content: "0",
background: "white",
display: "inline",
position: "relative",
borderRadius: "50%",
width: "36px",
height: "36px",
padding: "8px",
left: "15px",
border: "2px solid #666",
color: "#666",
textAlign: "center"
}
class Cart extends Component {
render() {
return(
<div className="cart" style={cartStyle}>
<div style={badgeStyle} > { this.props.cartProducts.length } </div>
</div>
);
}
}
https://codepen.io/stoerebink/pen/QvjYpo
高さと幅に影響を与えない 'div'に' display:inline'を与えています。 – Vucko
'display:inline-block;を使用してください。それはうまくいくでしょう。実際の例を確認してください:https://codepen.io/anon/pen/mmevXK –