Can someone please shed some light on this for me ... No matter what I do with the below code I always seem to have three columns but I just want two .. What I mean is the way the below shows on my page it is expecting another one to the right .. so it does not look like this
COL 1 ..... SPACE HERE........ COL 2
But instead
COL 1 COL 2
<Row className="show-grid text-center">
<Col xs={12} sm={4} className="person-wrapper">
<Image src="assets/image.jpg" circle className="profile-pic"/>
<h3></h3>
<Link to="/place">
<Button bsStyle="primary">click</Button>
</Link>
</Col>
<Col xs={12} sm={4} className="person-wrapper">
<Image src="assets/image1.jpg" circle className="profile-pic"/>
<h3></h3>
<Link to="/place">
<Button bsStyle="primary">click</Button>
</Link>
</Col>
</Row>
You should set an offset to each "resolution" you want to cover, in your case for sm:
<Row className="show-grid text-center">
<Col xs={12} sm={4} className="person-wrapper">
{/* your content goes here */}
</Col>
<Col xs={12} sm={{ span: 4, offset: 4 }} className="person-wrapper">
{/* your content goes here */}
</Col>
</Row>
The grid contains 12 columns, not 8. Your two sm columns need to add up to 12. Use sm={6} instead of sm={4}
<Row className="show-grid text-center">
<Col xs={12} sm={6} className="person-wrapper">
<Image src="assets/image.jpg" circle className="profile-pic"/>
<h3></h3>
<Link to="/place">
<Button bsStyle="primary">click</Button>
</Link>
</Col>
<Col xs={12} sm={6} className="person-wrapper">
<Image src="assets/image1.jpg" circle className="profile-pic"/>
<h3></h3>
<Link to="/place">
<Button bsStyle="primary">click</Button>
</Link>
</Col>
</Row>
Related
I am working on page layout using react-bootstrap. Along with that, I am using pure CSS for it. I have an alignment issue for Navbar on desktop view and mobile view. The components in the top bar should align with the components in the bottom bar in medium & large devices. The layout is different on the mobile device. In large devices Nav toggle bar expands and shrinks in the mobile devices when the user clicks on the toggle bar in the mobile screen, it expands down as shown in the figure. I hope the problem is clear. I have added the code and sample of the layout. Can someone help me to solve this issue?
CODE
<Container noGutters>
<Row className='main-nav d-flex' style={{ alignItems: 'center', justifyContent: 'flex-start' }}>
<Col sm={12} md={4} style={{ textAlign: 'center' }}>
<a href='/'>
visit mysite.com
</a>
</Col>
<Col sm={12} md={4} style={{ textAlign: 'center' }}>
<a href='#about-us'>
<picture>
<source srcSet={require('../public/assets/_logo.png?webp')} type='image/webp' />
<img className='cure-top-logo' src={'/assets/logo.png'} />
</picture>
</a>
</Col>
<Col sm={12} md={4}>
<Dropdown className='top-dropdown-container'>
<Dropdown.Toggle variant='success' id='dropdown'>
Choose an Item
</Dropdown.Toggle>
<Dropdown.Menu>
<Dropdown.Item href='/'>ITEM 1</Dropdown.Item>
<Dropdown.Item href='/'>ITEM 2</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</Col>
</Row>
</Container>
<Navbar style={{ maxHeight: '90px' }} className='sole-bottom-nav' expand={'lg'}>
<Container>
<div className='bottom-nav-logo-container'>
<a href='/cure-adventures/sole2soul'>
<div className='bottom-logo'>
<img alt='' src='assets/header.png' />
</div>
</a>
</div>
<Navbar.Toggle aria-controls='navlinks' />
<Navbar.Collapse id='navlinks'>
<Nav>
<Nav.Link className={activePage === 'about-us' ? ' active' : ''} href='/about-us'>
About Us
</Nav.Link>
<Nav.Link className={activePage === 'treks' ? ' active' : ''} href='/news'>
News
</Nav.Link>
<Nav.Link className={activePage === 'news' ? ' active' : ''} href='/contact'>
Contact us
</Nav.Link>
</Nav>
<div>
<a rel='noopener nofollow' target='_blank' href='https://twitter.com'>
<img src='/assets/twitter.png' width='25px' />
</a>
<a rel='noopener nofollow' target='_blank' href='https://facebook.com'>
<img src='/assets/facebook.png' width='25px' />
</a>
<a rel='noopener nofollow' target='_blank' href='https://instagram.com'>
<img src='/assets/instagram.png' width='25px' />
</a>
<a rel='noopener nofollow' target='_blank' href='/'>
<img src='/assets/linkdin.png' width='25px' />
</a>
</div>
<div>
<Button size={'lg'}>
button
</Button>
</div>
</Navbar.Collapse>
</Container>
</Navbar>
</div>
I'm designing a product detail page with React and Material UI. I tried to make the page responsive. But the description section keeps overlapping over the image until the screen is reduced to the mobile size. The content gets stacked at that point, but the images and text are not adjusting to the screen size.
I feel like it's something wrong with the image styling. How do I get the images to be responsive?
Here's my code
styling section
const useStyles = makeStyles((theme) => ({
content: {
flexGrow: 1,
padding: theme.spacing(3),
},
toolbar: {
display: "flex",
alignItems: "center",
justifyContent: "flex-end",
padding: theme.spacing(0, 1),
// necessary for content to be below app bar
...theme.mixins.toolbar,
},
}));
function
export default function ProductDetails() {
const classes = useStyles();
return (
<main className={classes.content}>
<div className={classes.toolbar} />
<Grid container spacing={3}> {/* image and description container */}
<Grid item xs={12} sm={6}> {/* image container */}
<Grid> {/* preview image */}
<img src="luxury-watch.jpg" width="600" id="preview" alt="" />
</Grid>
<Grid> {/* sub images */}
<img src="luxury-watch.jpg" width="140" id="img1" alt="" />
<img src="luxury-watch.jpg" width="140" id="img2" alt="" />
<img src="luxury-watch.jpg" width="140" id="img3" alt="" />
<img src="luxury-watch.jpg" width="140" id="img4" alt="" />
</Grid>
</Grid>
<Grid item xs={12} sm={6}> {/* description container */}
<div>
<h1>ROLEX</h1>
<p> .... </p>
<h2><span><sup>$</sup></span>1250</h2>
<Button variant="contained" color="secondary">ADD TO CART</Button>
</div>
</Grid>
</Grid>
</main>
);
}
I think you've missed a few props on your Grid elements. Try this:
export default function ProductDetails() {
const classes = useStyles();
return (
<main className={classes.content}>
<div className={classes.toolbar} />
<Grid container spacing={3}> {/* image and description container */}
<Grid item container xs={12} sm={6}> {/* image container */}
<Grid item> {/* preview image */}
<img src="luxury-watch.jpg" width="600" id="preview" alt="" />
</Grid>
<Grid item> {/* sub images */}
<img src="luxury-watch.jpg" width="140" id="img1" alt="" />
<img src="luxury-watch.jpg" width="140" id="img2" alt="" />
<img src="luxury-watch.jpg" width="140" id="img3" alt="" />
<img src="luxury-watch.jpg" width="140" id="img4" alt="" />
</Grid>
</Grid>
<Grid item container xs={12} sm={6}> {/* description container */}
<div>
<h1>ROLEX</h1>
<p> .... </p>
<h2><span><sup>$</sup></span>1250</h2>
<Button variant="contained" color="secondary">ADD TO CART</Button>
</div>
</Grid>
</Grid>
</main>
);
}
You can't apply xs attribute if your Grid items isn't a container and you console should be warning you about that too
You can use material ui breakpoints for responsiveness
const useStyles = makeStyles((theme) => ({
content: {
flexGrow: 1,
padding: theme.spacing(3),
},
toolbar: {
display: "flex",
alignItems: "center",
justifyContent: "flex-end",
padding: theme.spacing(0, 1),
// necessary for content to be below app bar
...theme.mixins.toolbar,
[theme.breakpoints.down('lg')]:{
width:'60%',
},
[theme.breakpoints.up('lg')]:{
width:'60%',
}
}
}));
I have a main element which is divided into a grid of 3 columns.
in the middle column I am displaying some listings.
each listing is a div element and has a react bootstrap card inside it.
I am trying to get the card to span 100% of the parent but that doesn't seem to be working for me.
React component
<div className="backfill">
<Row key={Listing_Id}>
<Card style={{ cursor: 'pointer' }} border="light" className="text-center fullCard" >
<Card.Body>
<Card.Title className="Title">
{Listing_Name}
<hr />
<Button className="Button" variant="outline-success" onClick={() => props.handleLikeDisLike(Listing_Id, 'Listing_Likes', Listing_Location)}> <Twemoji options={options} text=":+1:" /></Button>
<Badge className="Badge" variant="light">{Listing_Likes}</Badge>
<Button className="Button" variant="outline-danger" onClick={() => props.handleLikeDisLike(Listing_Id, 'Listing_DisLikes', Listing_Location)}><Twemoji options={options} text=":-1:" /></Button>
<Badge className="Badge" variant="light">{Listing_DisLikes}</Badge>
<hr />
<Button className="Button" variant="outline-info" ><Twemoji text=":pushpin:" /></Button>
<Badge className="Badge" variant="light">{Listing_Location}</Badge>
</Card.Title>
<Card.Text className="Listing" onClick={() => handleClick(Listing_Id)} >
<hr />
{ListingBody}
<ModalLayout
Listing_Location={Listing_Location}
Listing_Likes={Listing_Likes}
Listing_DisLikes={Listing_DisLikes}
Listing_Name={Listing_Name}
Listing_Id={Listing_Id}
handleLikeDisLike={props.handleLikeDisLike}
handleClose={closeModal}
show={showModal} />
</Card.Text>
</Card.Body>
</Card>
</Row>
<br />
</div >
CSS for div and Card elements
.backfill {
background-color: aqua;
}
.fullCard {
width:'100%';
}
I currently end up with the UI looking like this. Please can you help me sort this out. I want to get the card to be 100% of its parent div.
Just had to remove the single quotes from the CSS
.fullCard {
width:'100%';
}
had to become
.fullCard {
width:100%;
}
I used React and React-Bootstrap to build a website. I want to create a box with border inside a modal. This is my code.
.JSX file
<Modal.Header closeButton>
<Modal.Title>Preview</Modal.Title>
</Modal.Header>
<Modal.Body>
<Col md={6}>
<div className="previewCard">
<Col md={3}></Col>
<Col md={7}>
<p className="topicTH">Line1</p>
<p className="topicTH">Line2</p>
<p className="topicTH">Line3</p>
<p className="topicTH">Line4</p>
<p className="topicTH">Line5</p>
</Col>
<Col md={2}></Col>
</div>
</Col>
</Modal.Body>
<Modal.Footer></Modal.Footer>
.CSS file
div.previewCard{
border-style: dashed;
}
As you can see, there is noting inside the box even it put elements inside <div className="previewCard"></div>. How do I resolve this?
Instead of div use Row:
<Row className="previewCard">
I have one form on which all text fields are there and at the end there are 'save' and 'cancle' buttons. Between this last text field and buttons, there will be filename list that will populate dynamically as and when I will upload any file. Screenshot for the same is attached here. Size of this list is not fixed and thus, I want these buttons to shift down with every added file. I am not sure how can I adjust this movement of buttons dynamically. [see image 1]. And following is my current CSS code.
// Outermost div
.div-one {
position: absolute;
background-color: gainsboro;
height: 100%;
width: 50%;
}
// div for file list
.item-list {
width: 16em;
position: relative;
margin-left: -38px;
}
// div for buttons
.save-cancel-buttons-div{
position: relative;
top: 20%;
}
Following is my HTML code:
<div className="div-one1">
<Row>
<div className="item-list">
<Col xs={6} sm={6} md={6} lg={6}>
<If condition={this.state.files && this.state.files.length!=0}>
<ul style={{listStyle: 'None', fontSize: '16px'}}>
{this.state.files.map((value, index) => (
<li style={{paddingBottom: '5px', border:'5px'}}
key={`item-${index}`} >
<span>{value.file_name}
<span style={{paddingLeft: '20px'}}
onClick={() => this.onDeleteItem(value, index)}>
<Close size={20} paddingLeft={20}></Close>
</span>
</span>
</li>
))}
</ul>
</If>
</Col>
</div>
</Row>
<div className="save-cancel-buttons-div">
<Row>
<Col xs={3} sm={3} md={2} lg={2}>
</Col>
<Col xs={6} sm={6} md={6} lg={6}>
<Row>
<Col xs={6} sm={6} md={6} lg={6}>
<Button
value={<FormattedMessage id="saveBtn" defaultMessage="speichern" />}
fontSize={14}
minHeight={33}
minWidth={150}
backgroundColor="blue"
onClick={this.createNewDelivery}/>
</Col>
<Col xs={6} sm={6} md={6} lg={6}>
<Button
value={<FormattedMessage id="cancelBtn" defaultMessage="Zurück" />}
fontSize={14}
minHeight={33}
minWidth={150}
backgroundColor="red"
onClick={this.goBackToOfferedDeliveries}
/>
</Col>
</Row>
<Col xs={3} sm={3} md={2} lg={2}>
</Col>
<Col xs={6} sm={6} md={6} lg={6}>
</Col>
</Col>
</Row><br/>
</div>
</div>
Try to add a new container div for the save-cancel-buttons-div. Position the item-list and the container div relatively to their div-one parent container. Finally, position the save-cancel-buttons-div relatively to its container and add margin-left-right:auto so it centers inside it's parent div.
// div for file list
.item-list
{
position: relative; <--- this as first line of code
float:left; <--- add this so it takes a definite position
width: 16em;
margin-left: -38px;
}
// Put .save-cancel-buttons-div inside this div
.containerForSaveCancel
{
position:relative;
float:left;
width:100%;
text-align:center;
margin:0;
padding:0;
}
// div for buttons
.save-cancel-buttons-div
{
position: relative;
margin:5px auto 0 auto; <--- add this to center the div inside its parent
}