如何获得flexbox按钮以匹配CSS中的flexbox图像?
我试图将空间放在我的图像和我的按钮之间,并将其置于图像的中间。目前,我的图像被压制在一起,但我的按钮之间的差距很小。我试图使这些差距更大。以下是我的JS文件和我的CSS文件。关于我如何做的任何想法?预先感谢
import React from "react";
import { BrowserRouter as Router, Routes, Route, Link } from "react-router-dom";
import './Homepage.css';
import Accessories from './Accessories';
import DigitalPhotographs from './DigitalPhotographs';
import Fashion from './Fashion';
import Footwear from './Footwear';
import Jewellery from './Jewellery';
import Art from './Art';
function Homepage() {
return(
<>
<h3>Welcome to Luminous Butter. We dont sell Butter
we do sell vintage, Customised and pre-loved Fashion
Original Artwork
Plus, we have a great blog which has original stories and writing to keep you
entertained
</h3>
<div class= "container">
<div class= "image">
<img src="images/Fred.jpeg" alt="accessories" class= "rounded"
width="280px"/>
<img src="images/BlackonBlack.jpg" alt="photography" class= "rounded"
width="500px"/>
<img src="images/Boy.jpeg" alt="fashion" class= "rounded" width="300px"/>
</div>
</div>
<div class= "container">
<div class= "buttons">
<Link to="/Accessories"><button type="button">Accessories</button></Link>
<Link to="/DigitalPhotographs"><button type="button">Digital
Photographs</button></Link>
<Link to="/Fashion"><button type="button">Fashion</button></Link>
</div>
</div>
<div class= "container">
<div class= "image">
<img src="images/Campbell.jpeg" alt="footwear" class= "rounded" width="400px"/>
<img src="images/Scandal.jpeg" alt="jewellery" class= "rounded" width="300px"/>
<img src="images/bowiebig.jpeg" alt="art" class= "rounded" width="300px"/>
</div>
</div>
<div class= "container">
<div class= "buttons">
<Link to="/Footwear"><button type="button">Footwear</button></Link>
<Link to="/Jewellery"><button type="button">Jewellery</button></Link>
<Link to="/Art"><button type="button">Art</button></Link>
</div>
</div>
<div class= "container">
<form action="">
<h1> Sign-Up to Our Monthly Newsletter</h1>
</form>
<img src="images/email-icon.jpeg" alt="email subscribe icon" class= "rounded"
width="132px"/>
<div class= "email-box">
<input type= "email" name="" value="" placeholder="Please Enter Your E-Mail">
</input>
<button type="button">Subscribe</button>
</div>
</div>
</>
);
}
export default Homepage;
我的CSS页面
h3{
text-align: center;
margin: 5%;
}
.container{
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-around;
}
.container .button
{
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-around;
}
Im trying to put spaces in between my images and my buttons underneath and centre to my images. At the moment my images are squashed together but my buttons have small gaps in between. Im trying to make these gaps bigger. Below is my js file and my css file. Any ideas on how I do this? Thanks in advance
import React from "react";
import { BrowserRouter as Router, Routes, Route, Link } from "react-router-dom";
import './Homepage.css';
import Accessories from './Accessories';
import DigitalPhotographs from './DigitalPhotographs';
import Fashion from './Fashion';
import Footwear from './Footwear';
import Jewellery from './Jewellery';
import Art from './Art';
function Homepage() {
return(
<>
<h3>Welcome to Luminous Butter. We dont sell Butter
we do sell vintage, Customised and pre-loved Fashion
Original Artwork
Plus, we have a great blog which has original stories and writing to keep you
entertained
</h3>
<div class= "container">
<div class= "image">
<img src="images/Fred.jpeg" alt="accessories" class= "rounded"
width="280px"/>
<img src="images/BlackonBlack.jpg" alt="photography" class= "rounded"
width="500px"/>
<img src="images/Boy.jpeg" alt="fashion" class= "rounded" width="300px"/>
</div>
</div>
<div class= "container">
<div class= "buttons">
<Link to="/Accessories"><button type="button">Accessories</button></Link>
<Link to="/DigitalPhotographs"><button type="button">Digital
Photographs</button></Link>
<Link to="/Fashion"><button type="button">Fashion</button></Link>
</div>
</div>
<div class= "container">
<div class= "image">
<img src="images/Campbell.jpeg" alt="footwear" class= "rounded" width="400px"/>
<img src="images/Scandal.jpeg" alt="jewellery" class= "rounded" width="300px"/>
<img src="images/bowiebig.jpeg" alt="art" class= "rounded" width="300px"/>
</div>
</div>
<div class= "container">
<div class= "buttons">
<Link to="/Footwear"><button type="button">Footwear</button></Link>
<Link to="/Jewellery"><button type="button">Jewellery</button></Link>
<Link to="/Art"><button type="button">Art</button></Link>
</div>
</div>
<div class= "container">
<form action="">
<h1> Sign-Up to Our Monthly Newsletter</h1>
</form>
<img src="images/email-icon.jpeg" alt="email subscribe icon" class= "rounded"
width="132px"/>
<div class= "email-box">
<input type= "email" name="" value="" placeholder="Please Enter Your E-Mail">
</input>
<button type="button">Subscribe</button>
</div>
</div>
</>
);
}
export default Homepage;
and my css page
h3{
text-align: center;
margin: 5%;
}
.container{
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-around;
}
.container .button
{
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-around;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在将
显示:flex
和正当 - 符合:space-around
to。图像
类。是删除.image
包装器div还是在其中添加相同的样式。You're setting the
display: flex
andjustify-content: space-around
to your.container
class, but not to your.image
class. Whether delete the.image
wrapper div or add the same styles to it.