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>
Related
So I'm using react-bootstrap to create my Navbar and I want the Navbar link to redirect to the same page but to the spesific part, I tried using href and assigning id into each div, but it wont' work. How to fix this ? Thanks before
Here's my code:
Navbar part
<Navbar className="MainHeader" expand="lg">
<Navbar.Brand as={Link} to={"/"}>
<img src="#" className='encotekiLogo' alt="main_logo"/>
</Navbar.Brand>
<Navbar.Toggle aria-controls="basic-navbar-nav" />
<Navbar.Collapse className="justify-content-end">
<Nav>
<Nav.Link as={Link} href='about' to={'/#about'}>About</Nav.Link>
<Nav.Link as={Link} to={"/Gallery"}>Gallery</Nav.Link>
</Nav>
</Navbar.Collapse>
</Navbar>
This is the code for my part of the page:
<div className= 'aboutUs' id='about'>
<Row className='mb-4' lg={12}>
<h1 style={{
color: '#246234',
}}>
About<br/>
Us
</h1>
</Row>
</div>
Hi guys so I'm trying to create some website using react-bootstrap and I wanted to redirect my user to another website/link when they click on some logo on my footer, How can I do that in react ? because I realize that tag will only redirect the path of our website.
Here's my code:
import { Container, Row, Col } from "react-bootstrap"
import '../CSS/Footer.css'
const Footer = () => {
return (
<Container fluid={true} className="p-0 footerContainer">
<Row>
<Col sm={12} lg={4} className="text-center footerright">
<h3>Follow Us</h3>
<hr style={{border:'2px solid', color:'#FFFFFF', width:'25.7%', margin: 'auto'}}></hr>
<img src="FBLogo.jpg"></img>
<img src="IGLogo.jpg"></img>
</Col>
</Row>
<Row>
<Col sm={12} lg={12} className="text-center">
<hr></hr>
<p>Copyright © 2014 <br></br>All Rights Reserved</p>
</Col>
</Row>
</Container>
)
}
export default Footer
Just like in normal HTML, You will wrap an image with a link tag:
<img src="FBLogo.jpg"/>
<img src="IGLogo.jpg"/>
Or using a workmap:
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/ef/Stack_Overflow_icon.svg/768px-Stack_Overflow_icon.svg.png" alt="Workplace" usemap="#workmap" width="400" height="379">
<map name="workmap">
<area shape="rect" coords="34,44,270,350" alt="stack_overflow" href="https://www.google.com/">
</map>
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 written a Portfolio.js file using react library react-bootstrap Carousel.js to create an uncontrolled carousel. My code displays the slides in vertical instead of switching as Carousel, https://react-bootstrap.github.io/components/carousel/. My carousel behavior does not work
Posting the code below: https://codesandbox.io/s/stoic-beaver-6j1ie?file=/src/component/Project.js
import React, { Component } from "react";
import TextBlock from "./TextBlock";
import "../styles/Styles.css";
import { Row, Col, Carousel } from "react-bootstrap";
import ModalItem from "./ModalItem.js";
import model from "../assets/img/portfolio/3d-tool.PNG";
import portfolio from "../assets/img/portfolio/download.svg";
import americanDream from "../assets/img/portfolio/download.jpg";
import PrevButton from "../assets/img/PrevButton.svg";
import NextButton from "../assets/img/NextButton.svg";
import features from "../assets/img/portfolio/model.gif";
import photo from "../assets/img/portfolio/portfolio.gif";
import styled from "styled-components";
// import 'bootstrap/dist/css/bootstrap.min.css';
const StyledCarousel = styled(Carousel)`
.carousel-control-prev-icon {
background-image: url(${PrevButton});
}
.carousel-control-next-icon {
background-image: url(${NextButton});
}
.carousel-control-prev-icon,
.carousel-control-next-icon {
width: 2em;
height: 2em;
}
.carousel-control-next,
.carousel-control-prev {
top: 40%;
bottom: auto;
z-index: 20;
}
`;
class Portfolios extends Component {
state = {
modals: [
{
id: 1,
open: false
},
{
id: 2,
open: false
},
{
id: 3,
open: false
}
]
};
onOpenModal = (id) => {
this.setState({
modals: this.state.modals.map((item) => {
if (item.id === id) {
item.open = true;
}
return item;
})
});
};
onCloseModal = (id) => {
this.setState({
modals: this.state.modals.map((item) => {
if (item.id === id) {
item.open = false;
}
return item;
})
});
};
getOpen = (id) => {
const open = this.state.modals;
return open[id - 1].open;
};
render() {
return (
<section id="portfolio">
<div className="content">
<h2>MY PROJECTS</h2>
<div id="Projects" className="Projects">
<Row className="no-gutters" data-aos="fade-up" data-aos-delay="100">
<Col sm={12}>
<TextBlock title="Go over some projects I have worked on">
<div style={{ paddingTop: "0.5em" }}>
<Carousel>
<Carousel.Item>
<img
className="d-block"
src={model}
width="70%"
alt="First slide"
/>
<Carousel.Caption>
<h3>3D Construction Tool</h3>
<p>
A React website to render 3D model in astronomy,
built with React front-end, Node server, WebGL,
Google Cloud Platform and Neural Network
<br />
<button
className="Styled-Button"
onClick={() => {
this.onOpenModal(1);
}}
>
Details
</button>
<a
className="Styled-Button"
href="https://github.com/tuyenphk/3D-RECONSTRUCTION-TOOL"
target="_blank"
rel="noopener noreferrer"
>
Code
</a>
</p>
</Carousel.Caption>
</Carousel.Item>
<Carousel.Item>
<img
className="d-block"
src={portfolio}
width="70%"
alt="Third slide"
/>
<Carousel.Caption>
<h3>Portfolio Website</h3>
<p>
My personal portfolio responsive website, built with
React to let viewers get to know a little bit more
about me, my projects and my designs
<br />
<button
className="Styled-Button"
onClick={() => {
this.onOpenModal(2);
}}
>
Details
</button>
<a
className="Styled-Button"
href="https://github.com/tuyenphk/porfolio-website"
target="_blank"
rel="noopener noreferrer"
>
Code
</a>
</p>
</Carousel.Caption>
</Carousel.Item>
<Carousel.Item>
<img
className="d-block"
src={americanDream}
width="70%"
alt="Third slide"
/>
<Carousel.Caption>
<h3>American Dream</h3>
<p>
My first web application project
<br />
<a
className="Styled-Button"
href="http://cis-linux2.temple.edu:8080/SP20_3308_tuh39709/#/home"
target="_blank"
rel="noopener noreferrer"
>
Live
</a>
<a
className="Styled-Button"
href="https://github.com/tuyenphk/Pham_web"
target="_blank"
rel="noopener noreferrer"
>
Code
</a>
</p>
</Carousel.Caption>
</Carousel.Item>
</Carousel>
<ModalItem
isOpen={this.getOpen(1)}
onClose={() => {
this.onCloseModal(1);
}}
>
<TextBlock title="3D Reconstruction Tool">
<Row className="no-gutters">
<Col md={7}>
<p>
3D-Reconstruction Tool is a fun, enjoyable, and
informative web application designed for
experimentation, research, and casual learning.
The application's cloud-hosted neural network
offers symmetry detection services for
2-dimensional astronomy images, and reproduces
them in a 3-dimensional format. Cloud-based
machine learning has rapidly evolved into a vital
and sophisticated aspect of modern software
development. The goal of the 3D Reconstruction
Tool aims to explore and transform these
components into an entertaining, informative
platform.
</p>
</Col>
<Col md={5}>
<figure
style={{ maxWidth: "280px", textAlign: "center" }}
>
<img
src={features}
alt="3d demo"
style={{ maxWidth: "100%", height: "auto" }}
></img>
<figcaption style={{ textAlign: "center" }}>
<i>3D Reconstruction Tool's chatbot feature</i>
</figcaption>
</figure>
</Col>
</Row>
<Row>
<Col>
<h2>
<b>
Features: Web application is built by React
Hook, instantiated Nodejs, serviced on Google
Compute Engine with some features
</b>
</h2>
<ul
style={{
paddingLeft: "1.1em",
textAlign: "left"
}}
>
<li>
There are 4 tabs: Home, Modelling, Resource,
Team to navigate.
</li>
<li>
Upload functionality & sent to Google Cloud
Storage bucket.
</li>
<li>Render button for modelling 3D model.</li>
<li>
Utilize the ‘Search’ functions to find 2D
images.
</li>
<li>
Ability to search, obtain, and display their
rendered images
</li>
</ul>
<h2>
<b>Technologies used:</b>
</h2>
<p>
React, React Hook, WebGL, Three.js, Node, Express,
Google Cloud Platform, Neraul-Network
</p>
<p>
<em>
Special thanks to my collaborators: Khai Nguyen,
Elizaveta Lizaibeme, and Lauren Kimpel from
Temple University's Class of 2020!
</em>
</p>
</Col>
</Row>
</TextBlock>
</ModalItem>
<ModalItem
isOpen={this.getOpen(2)}
onClose={() => {
this.onCloseModal(2);
}}
>
<TextBlock title="Portfolio Website">
<Row className="no-gutters">
<Col md={7}>
<p>
My personal portfolio responsive website, built
with React to showcase my projects, my photoshop
designs and let viewers get to know a little bit
more about me.
</p>
</Col>
<Col md={5}>
<figure
style={{ maxWidth: "280px", textAlign: "center" }}
>
<img
src={photo}
alt="3d demo"
style={{ maxWidth: "100%", height: "auto" }}
></img>
<figcaption style={{ textAlign: "center" }}>
<i>Portfolio's chatbot feature</i>
</figcaption>
</figure>
</Col>
</Row>
<Row>
<Col>
<h2>
<b>Features:</b>
</h2>
<ul
style={{
paddingLeft: "1.1em",
textAlign: "left"
}}
>
<li>Display the home page.</li>
<li>
Describe about myself to let employers
understand me.
</li>
<li>
More details about projects I have worked on.
</li>
<li>
Display some designs I have experienced in
Illustrator, Photoshop, and Indesign.
</li>
<li>
A contact form for employers get in touch with
me.
</li>
</ul>
<h2>
<b>Technologies used:</b>
</h2>
<p>React, Firebase-hosting, Formspree</p>
</Col>
</Row>
</TextBlock>
</ModalItem>
</div>
</TextBlock>
</Col>
</Row>
</div>
</div>
</section>
);
}
}
export default Portfolios;
Can someone spend your time to help me with this? I have really appreciated it!
I found my answer here
add this to index.html under public folder (for react app)
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">
So I am creating a personal site using react-bootstrap. And here is what the site looks like right now.
The navbar is
<Navbar collapseOnSelect expand="lg" bg="dark" variant="dark">
<Navbar.Brand href="#home">React-Bootstrap</Navbar.Brand>
<Navbar.Toggle aria-controls="responsive-navbar-nav" />
<Navbar.Collapse id="responsive-navbar-nav">
<Nav>
<Nav.Link href="#features">Features</Nav.Link>
<Nav.Link href="#pricing">Pricing</Nav.Link>
</Nav>
<Nav className="ml-auto">
<Nav.Link href="#deets">More deets</Nav.Link>
<Nav.Link eventKey={2} href="#memes">
Dank memes
</Nav.Link>
</Nav>
</Navbar.Collapse>
</Navbar>
and the introduction looks like
<Row>
<Col md={{ span: 4, offset: 2 }}>
<p id='hey'>Hey, I am Max! </p> </Col> </Row>
I really want to shift the navbar to the right with "offset: 2" so that the brand ("React-Bootstrap" in the navbar) can line up with the "Hey, I am Max". I've tried adding padding or margin to Navbar.Brand but it doesn't really work. Is there a way for me to directly add offset:2 to the Navbar.Brand element? Or what might be the best way to accomplish this?