import "react-responsive-carousel/lib/styles/carousel.min.css";
import { Carousel } from "react-responsive-carousel";
function App() {
return (
<Carousel showArrows={true}>
<div>
<img src="../assets/1.jpeg" alt="image1" />
<p className="legend">Legend 1</p>
</div>
<div>
<img src="../assets/2.jpeg" alt="image2" />
<p className="legend">Legend 2</p>
</div>
<div>
<img src="../assets/3.jpeg" alt="image3" />
<p className="legend">Legend 3</p>
</div>
</Carousel>
);
}
export default App;
i added the css file in App component similar like react-responsive-carousel but it is not working
carousel.min.css
import "react-responsive-carousel/lib/styles/carousel.min.css";
import { Carousel } from "react-responsive-carousel";
It should be working but not sure why this is happening
I don't know about this library, But I can see you are not doing something complicated with your carousel. So basically why don't you create one for yourself?
I have a base code that could help you in this matter.
I create a carousel with React and Static UI(HTML, CSS, JS).
I think it can actually help you out.
replit, codesandbox, Stackblitz
these versions are written with html css js and nothing else.
replit, codesandbox, Stackblitz
In your scenario I will do this:
const modalSlidesContainer = document.querySelector(".modal-slides-container");
const modalWidth = 300;
let modalPage = 0;
const nextPage = () => {
modalPage++;
modalSlidesContainer.style.margin = `0px 0px 0px -${modalWidth * modalPage}px`;
};
const previousPage = () => {
modalPage--;
modalSlidesContainer.style.margin = `0px 0px 0px -${modalWidth * modalPage}px`;
};
/* you set root to define varibales */
:root {
--modal-width: 300px;
--modal-height: 400px;
--number-of-pages: 5;
}
html body{
margin: 0px;
}
.modal-background{
background-color: rgba(0,0,0,0.4);
position: absolute;
top: 0;
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
z-index: 0;
}
.modal-boundary{
width: var(--modal-width); /* the width boundary must be as same as every modal slide*/
height: var(--modal-height);
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
overflow-x: hidden;
z-index: 10;
/* the max width must be as same as the width of modal ModalBoundary*/
#media screen and (max-width: var(--modal-width)) {
width: 100vw;
height: 100vh;
}
}
/* This container contains every slide you gonna use in your modal */
.modal-slides-container{
min-width: calc(var(--modal-width) * var(--number-of-pages)); /* The width must be total width of all the slide you gonna use */
height: var(--modal-height);
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
background-color: white !important;
/*here is how to control carousel movement*/
margin: 0px; /*this how we control the place of the modal*/
transition: margin 1s; /*this how you control the animation of carousel when it's changing steps */
}
.modal-slide{
width: var(--modal-width);
height: var(--modal-height); /* in this scenario the total height of slide must be as same as modal height*/
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: white !important;
}
.button-container{
width: 100%;
margin-top: 10px;
display: flex;
flex-direction: row;
}
.navigation-button{
margin: auto;
}
<body>
<div class="modal-background">
<div class="modal-boundary">
<div class="modal-slides-container">
<div class="modal-slide">
<img alt="first image" src="https://picsum.photos/200/200" />
<p> Legend One </p>
<div class="button-container">
<button onclick="nextPage()" class="navigation-button">
next
</button>
</div>
</div>
<div class="modal-slide">
<img alt="second image" src="https://picsum.photos/200/200" />
<p> Legend Two </p>
<div class="button-container">
<button onclick="previousPage()" class="navigation-button">
previous
</button>
<button onclick="nextPage()" class="navigation-button">
next
</button>
</div>
</div>
<div class="modal-slide">
<img alt="third image" src="https://picsum.photos/200/200" />
<p> Legend Three </p>
<div class="button-container">
<button onclick="previousPage()" class="navigation-button">
previous
</button>
<button onclick="nextPage()" class="navigation-button">
next
</button>
</div>
</div>
<div class="modal-slide">
<img alt="fourth image" src="https://picsum.photos/200/200" />
<p> Legend Four </p>
<div class="button-container">
<button onclick="previousPage()" class="navigation-button">
previous
</button>
<button onclick="nextPage()" class="navigation-button">
next
</button>
</div>
</div>
<div class="modal-slide">
<img alt="fifth image" src="https://picsum.photos/200/200" />
<p> Legend five </p>
<div class="button-container">
<button onclick="previousPage()" class="navigation-button">
previous
</button>
</div>
</div>
</div>
</div>
</div>
</body>
I hope this helps you.^-^
I'm trying to do an about page and i need 3 sets of elements inside a vertical slider, so i picked swiperjs. Without the carousel, they were working just fine as far as the grid goes, but now the columns are extremely tall and the elements aren't in their correct rows. Here's how it looks on the jsx
<container className = {styles.sobreGeral}>
<div className={styles.parent}>
<Swiper
direction={"vertical"}
pagination={{clickable: true,}}
modules={[Pagination]}
>
<SwiperSlide>
<div className={styles.div1}>
<img src="sobre.jpg" alt="alt" className={styles.imagem} />
</div>
<div className={styles.div2}>
<img src="logo-sobre.jpg" alt="logo" className={styles.imagem} />
</div>
<div className={styles.div3}>
<p>text</p>
</div>
</SwiperSlide>
<SwiperSlide>
<div className={styles.div1}>
<img src="sobre-rita.jpg" alt="pic" className={styles.imagem} />
</div>
<div className={styles.div2}>
<h2>Rita </h2>
</div>
<div className={styles.div3}>
<p>text</p>
</div>
</SwiperSlide>
<SwiperSlide>
<div className={styles.div1}>
<img src="sobre-jose.jpg" alt="pic" className={styles.imagem} />
</div>
<div className={styles.div2}>
<h2>Jose </h2>
</div>
<div className={styles.div3}>
<p>text</p>
</div>
</SwiperSlide>
</Swiper>
</div>
</container>
}
and here's how the css is setup
.sobreGeral{
display: flex;
margin-top: 150px;
}
.contato{
display: flex;
justify-content: center;
}
.parent {
display: grid;
grid-template-columns: repeat(9, 1fr);
width: 100%;
grid-template-rows: repeat(8, 1fr);
grid-column-gap: 0px;
grid-row-gap: 0px;
}
.div1 {
grid-area: 2 / 3 / 6 / 6;
max-width: fit-content;
padding-left: 10%;
}
.div2 {
grid-area: 2 / 6 / 4 / 11;
max-width: fit-content;
}
.div3 {
grid-area: 4 / 6 / 6 / 8;
}
without the swiper, things were in their proper places, but as it is it's not working
I want all cards in my grid to have equal height. I've been trying for hours with chrome, testing various combinations but I can't achieve the desired result. I want the content part of the card (pink) to expand so that everything is in the same line.
Grid cells are perfect. But if I flex grow the card or set it to 100% height, it fills the grid item (which is shown in picture 1) with paper (picture 2). I did the same thing for all the children (especially the text area), but they won't expand.
Tried stretching, changing displays, heights etc. Want to avoid a fixed height (even dependent on viewport) or fixed max height at all costs. Any ideas?
Edit: Maybe it's worth mentioning that the closest I've gotten to the desired result is setting display: content at the CardActionArea sub-element. Card is exactly as I want it except that it pushes my text at the bottom.
Here's the code of my styles and my first card - I'll leave the comments in to show some of the things that have been tried and tested (some code is also irrelevant but I'll leave it in in case something sabotages what I'm trying to do):
const useStyles = makeStyles(theme => ({
root: {
flexGrow: 1
},
grid: {}, //grid works exactly as I want it
gridItem: {
[theme.breakpoints.up("md")]: {
padding: "32px !important"
}
// display: "flex",
// flexDirection: "column",
// justifyContent: "space-between",
// alignItems: "stretch"
// [theme.breakpoints.down("sm")]: {
// padding: theme.spacing(0)
// }
},
card: {
"&:hover": {
boxShadow:
"0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(255, 255, 255, 0.23)",
// margin: "-10px auto 0",
// transform: "scale(1.01)",
// boxShadow: "-6px 4px 3px rgba(38, 38, 38, 0.2)",
// top: "-4px",
transition: ["boxShadow", "margin"],
transitionDuration: 300
},
display: "flex",
flexFlow: "column"
// flexDirection: "column",
// justifyContent: "space-between",
// alignItems: "stretch",
// height: "100%"
// maxWidth: "300px",
// maxHeight: 345
// boxShadow:
// "10px 10px 5px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.43)"
// display: "block",
// width: "100%",
},
media: {
height: "auto",
width: "100%",
objectFit: "cover"
// margin: "-70px auto 0",
// width: "80%",
// height: 140,
// borderRadius: "4px",
// boxShadow: "0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23)",
// position: "relative",
// zIndex: 1000
},
content: {
background: "linear-gradient(to right, #ee9ca7, #ffdde1)",
padding: "10px",
flexGrow: 1
// display: "flex"
// flexDirection: "column",
// justifyContent: "space-between",
// alignItems: "stretch",
// height: "100%"
},
contHead: {
color: "black",
marginBottom: "3px"
},
contText: {
color: "black"
},
buttonArea: {
background: "linear-gradient(to right, #000000, #434343)",
// display: "flex", //card has flex by default
flexFlow: "wrap",
justifyContent: "center",
padding: "0"
},
buttons: {
// backgroundColor: "white",
padding: "0",
minHeight: "29px",
marginLeft: "0 !important",
marginTop: "5px",
marginBottom: "5px"
},
icons: { color: "white", fontSize: "1.8rem" },
iconsTBA: { color: "#9c7e82", fontSize: "1.3rem" },
toolTips: {
// backgroundColor: "#f5f5f9",
backgroundColor: "rgba(0, 0, 0, 1)",
maxWidth: 350,
// // maxHeight: 100,
fontSize: theme.typography.pxToRem(14),
// border: "1px solid #dadde9",
// // transform: "translate(100px, 200px) rotate(50deg)"
// // transform: "translate(50%,90%)"
// marginLeft: "23vw",
// marginTop: "90vh",
[theme.breakpoints.down("sm")]: {
marginBottom: "35vh"
}
},
toolTipsCard: {
fontSize: theme.typography.pxToRem(20)
}
}));
//Tooltip info
const rpgTT = "test";
const Games = () => {
const classes = useStyles();
return (
<div className="full-container-2">
<div className={classes.root}>
<Grid className={classes.grid} container spacing={3}>
<Grid className={classes.gridItem} item xs={12} sm={6} md={4} lg={4}>
<Card className={classes.card}>
<Tooltip
classes={{ tooltip: classes.toolTipsCard }}
TransitionComponent={Zoom}
title="Play"
placement="top"
>
<CardActionArea>
<CardMedia className={classes.media} image={pic1} />
<CardContent className={classes.content}>
<Typography
className={classes.contHead}
gutterBottom
variant="h5"
component="h2"
>
Game Title
</Typography>
<Typography
className={classes.contText}
variant="body2"
color="textSecondary"
component="p"
>
This is a small string
</Typography>
</CardContent>
</CardActionArea>
</Tooltip>
<CardActions className={classes.buttonArea}>
<Button className={classes.buttons}>
<FontAwesomeIcon
title="Not Available Yet"
className={classes.iconsTBA}
icon={faWindows}
/>
</Button>
<Button className={classes.buttons}>
<FontAwesomeIcon
title="Not Available Yet"
className={classes.iconsTBA}
icon={faLinux}
/>
</Button>
<Button className={classes.buttons}>
<FontAwesomeIcon className={classes.icons} icon={faGithub} />
</Button>
<Tooltip
classes={{ tooltip: classes.toolTips }}
TransitionComponent={Zoom}
title={rpgTT}
placement="bottom"
>
<Button className={classes.buttons}>
<FontAwesomeIcon
className={classes.icons}
icon={faInfoCircle}
/>
</Button>
</Tooltip>
</CardActions>
</Card>
</Grid>
Make each card a flexbox and give the info panel a flex-grow: 1:
.grid{
display:grid;
grid-template-columns: 1fr 1fr;
}
.card {
display: flex;
flex-flow: column;
margin-right: 10px;
}
.card img{
width: 100%;
}
.card .info{
background-color: pink;
flex-grow: 1;
}
<div class="grid">
<div class="card">
<img src="http://placekitten.com/200/200" />
<div class="info">
<h1>Title</h1>
<p>Text</p>
</div>
</div>
<div class="card">
<img src="http://placekitten.com/200/200" />
<div class="info">
<h1>Title</h1>
<p>Text</p>
<p>Text</p>
<p>Text</p>
</div>
</div>
</div>
Found the culprit. It was the CardActionArea (a subcomponent of the card that make it clickable and contains the ripple effect of MUI).
The desired result is achieved only when this area has all of the following properties, so that the content fits into that area:
flexGrow: 1,
display: "flex",
flexDirection: "column",
alignItems: "stretch"
Thanks to everyone for discussing it, helped me approach the problem in a better way and started commenting out the sub-elements of the card one by one and found the problem. Cheers!
Tried to achieve wanted card behavior in a very simple way, I hope that would help:
.container {
display: flex;
flex-wrap: wrap;
}
.card {
border: 4px solid #827d7d;
border-radius: 5px;
margin: 8px;
display: flex;
flex-direction: column;
}
.card_header {
background-color: grey;
}
.card_content {
background-color: yellow;
height: 100%;
}
h1, p {
margin: 0;
}
<div class="container">
<div class="card">
<div class="card_header">
<h1>I'm header</h1>
</div>
<div class="card_content">
<p>I'm different amount of content</p>
</div>
</div>
<div class="card">
<div class="card_header">
<h1>I'm header</h1>
</div>
<div class="card_content">
<p>I'm different amount of content</p>
<p>I'm different amount of content</p>
</div>
</div>
<div class="card">
<div class="card_header">
<h1>I'm header</h1>
</div>
<div class="card_content">
<p>I'm different amount of content</p>
<p>I'm different amount of content</p>
<p>I'm different amount of content</p>
</div>
</div>
<div class="card">
<div class="card_header">
<h1>I'm header</h1>
</div>
<div class="card_content">
<p>I'm different amount of content</p>
</div>
</div>
<div class="card">
<div class="card_header">
<h1>I'm header</h1>
</div>
<div class="card_content">
<p>I'm different amount of content</p>
<p>I'm different amount of content</p>
</div>
</div>
<div class="card">
<div class="card_header">
<h1>I'm header</h1>
</div>
<div class="card_content">
<p>I'm different amount of content</p>
<p>I'm different amount of content</p>
<p>I'm different amount of content</p>
</div>
</div>
</div>
I am trying to make a transition when showing the side navigation and it works fine when opening and closing. The problem is when the page first loads the sidebar is shown withdrawning. Here is the code:
<div>
<span style={{ cursor: 'pointer' }} onClick={ this.showOrHideNav }>☰</span>
<Transition in={this.state.navStanje} timeout={ 500 }>
{ state =>
<div className={`navigacija navigacija-${state}`}>
<a to="javascript:void(0)" className="backButton" onClick={ this.showOrHideNav }><Typography variant="h7">×</Typography></a><br />
<div style={ profileDiv } >
<img src={require('../../images/campus.svg')} style={ imageStyle } height='100%'/><br />
<Typography style={ profileName }>Ime Prezime</Typography>
</div>
<div className="fadingLine"></div>
<Typography variant="h4" style={{ color: '#FFEB3B', marginTop: '3%' }}>Neki naslov</Typography>
<a to="#" className="linkovi">About</a><br />
<a to="#" className="linkovi">Services</a><br />
<a to="#" className="linkovi">Clients</a><br />
<a to="#" className="linkovi">Contact</a><br />
</div>
}
</Transition>
</div>
And here is the CSS I am using:
.navigacija {
position: fixed;
top: 8%;
left: 0;
height: 100%;
padding-top: 1%;
background: #2B3944;
width: 20%;
display: block;
overflow-x: hidden;
z-index: 2;
transition: all 0.5s linear;
}
.navigacija.navigacija-entering {
transform: translateX(0%);
}
.navigacija.navigacija-exited {
transform: translateX(-100%);
}
How can I prevent the withdrawing of the sidebar when the page loads?
Set the initial CSS transform property to transform: translateX(-100%); that way it will initially be hidden
I am using react bootstrap v1.0.0-beta.5 which uses bootstrap 4.
I am trying to create a header that aligns text on one side and an ellipsis on the other that will drop down actions when you click it.
I have attemped to use
<FaEllipsisH className="justify-content-end"/>
What should I be doing?
<Card style={{ width: '22rem' }} className="pCard" border="dark">
<Card.Header>
<FaAmazon/> {product.content}
<FaEllipsisH className="justify-content-end"/>
</Card.Header>
<Card.Body>
<Card.Title> <FaFileInvoice/> <span className="Home orderNo"><a href={`/products/${product.productId}`}>{product.productId}</a></span></Card.Title>
<Card.Text>Item</Card.Text>
</Card.Body>
</Card>
Associated CSS
.Home .pCard {
font-size: 0.8em;
margin-bottom: 10px;
margin-top: 5px;
display: flex;
}
Use the justify-content: space-between from flexbox. You can use Bootstrap's flex utility classes:
<Card.Header className="d-flex justify-content-between">