I need to have my tooltip display above the grid table, but it keeps getting covered up by the row bellow (I will change it later so it shows only when hovered). I have tried, position absolute z-index position relative to multiple containers in different combinations, but nothing gets the tool tip over the row bellow. Thanks for the help!
<TableContainer>
<Row>
<ItemContainer>
<TreatmentContainer>
<TreatmentIconContainer>
<AttachmentIcon width={15} height={15} color={Gray1} />
</TreatmentIconContainer>
<TreatmentIconContainer>
<DownloadIcon width={15} height={15} color={Gray1} />
</TreatmentIconContainer>
</TreatmentContainer>
<ToolTip>hello</ToolTip>
</ItemContainer>
<ItemContainer>
<TreatmentContainer>
<TreatmentIconContainer>
<AttachmentIcon width={15} height={15} color={Gray1} />
</TreatmentIconContainer>
<TreatmentIconContainer>
<DownloadIcon width={15} height={15} color={Gray1} />
</TreatmentIconContainer>
</TreatmentContainer>
<ToolTip>hello</ToolTip>
</ItemContainer>
<ItemContainer>
<TreatmentContainer>
<TreatmentIconContainer>
<AttachmentIcon width={15} height={15} color={Gray1} />
</TreatmentIconContainer>
<TreatmentIconContainer>
<DownloadIcon width={15} height={15} color={Gray1} />
</TreatmentIconContainer>
</TreatmentContainer>
<ToolTip>hello</ToolTip>
</ItemContainer>
</Row>
<Row>
<TreatmentRow /> // this is the same as you see above
</Row>
<Row>
<TreatmentRow />
</Row>
<Row>
<TreatmentRow />
</Row>
<Row>
<TreatmentRow />
</Row>
<Row>
<TreatmentRow />
</Row>
</TableContainer>
const TableContainer = styled.View`
background: ${LightNeutral};
display: grid;
justify-items: center;
row-gap: 8px;
padding: 0px 0px 24px 0px;
`;
const Row = styled.View`
background: ${White};
display: grid;
padding: 0px 11px;
align-items: center;
border-radius: 16px;
max-width: 1200px;
display: grid;
justify-items: center;
`;
const ItemContainer = styled.View`
display: table-row-group;
margin: 16px 1px;
width: 72px;
display: grid;
justify-items: center;
`;
const TreatmentContainer = styled.View<{color: string}>`
display: flex;
width: 72px;
height: 72px;
padding: 8px;
background: ${LightNeutral};
border-radius: 16px;
${({color}) => `border-color: ${color};`}
border-width: 0;
border-top-width: 19px;
border-style: 'dashed';
flex-wrap: wrap;
align-content: flex-end;
justify-content: flex-end;
flex-direction: row;
`;
const TreatmentIconContainer = styled.Pressable`
margin: 3px;
`;
const ToolTip = styled.Text`
position: absolute;
z-index: 2;
top: 10;
width: 120px;
height: 74px;
margin: 21px 0 0;
border-radius: 8px;
background: ${Dark}
color: ${White}
`;
Related
I have a pretty simple website, which renders a background image, a header, a footer, and some body text.
When I view the site from Google Dev Tools mobile inspector. The text sits above the footer as expected. When I view the site from an actual iphone the text is shown at the very bottom of the page (behind the footer).
App.js
return (
<div className={style.app}>
<Header setNav={setNav} nav={nav} />
<Routes>
<Route
exact
path="/"
element={
<Mobile
setNav={setNav}
nav={nav}
menuList={menuList}
setFilter={setFilter}
/>
}
/>
<Route
exact
path="/directions"
element={
<Directions
setNav={setNav}
nav={nav}
filter={filter}
setFilter={setFilter}
menuList={menuList}
/>
}
/>
</Routes>
<MobileNavOneButton setNav={setNav} setFilter={setFilter} />
</div>
);
the css for style.app is:
.app {
background-image: url("../CompanyImages/Port507BackgroundImage.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
position: fixed;
height: 100vh;
width: 100vw;
max-height: 100vh;
max-width: 100vw;
background-size: cover;
z-index: -999;
}
Mobile.js
import React from "react";
import style from "./Mobile.module.css";
const Mobile = () => {
return (
<div className={style.app}>
<div className={style.mainContent}>
<div className={style.address}>128 W 2nd St, Winona, MN 55987</div>
</div>
</div>
);
};
export default Mobile;
css for mobile.js
html,
body {
margin: 0;
/* height: 100% */
}
.app {
height: calc(100vh - 8rem);
width: 100vw;
background-size: cover;
display: flex;
justify-content: center;
margin-top: 5rem;
}
.mainContent {
text-align: center;
color: white;
width: 100%;
display: flex;
align-self: flex-end;
margin-bottom: 1.5rem;
margin-left: 1rem;
}
Footer.js
import React from "react";
import { useNavigate } from "react-router-dom";
import style from "./MobileNavOneButton.module.css";
import HomeIcon from "#mui/icons-material/Home";
import ExploreIcon from "#mui/icons-material/Explore";
const MobileNavOneButton = ({ setNav }) => {
const navigate = useNavigate();
return (
<div className={style.NavBar}>
<div
className={style.NavButton}
onClick={() => {
navigate("../directions", { replace: true });
setNav(false);
}}
>
<ExploreIcon style={{ fontSize: "1.25rem", color: "#000000" }} />
<div className={style.buttonText}>Directions</div>
</div>
</div>
);
};
export default MobileNavOneButton;
css for the footer
.buttonText {
font-size: 0.75rem;
font-family: Montserrat-Light;
text-decoration: none;
color: black;
}
.NavBar {
width: 100%;
float: none;
display: flex;
height: 3rem;
overflow: hidden;
position: fixed;
bottom: 0;
z-index: 999;
background-color: rgba(150, 150, 150, 0.8);
}
.NavButton {
align-items: center;
justify-content: center;
/* border: 1px solid black; */
/* background-color: rgba(150, 150, 150, 0.8); */
border-radius: 0;
float: left;
display: flex;
flex-direction: column;
font-size: 1rem;
font-family: Montserrat-Light;
text-align: center;
width: 100%;
text-decoration: none;
color: #222222;
}
.NavButton:focus {
outline: none !important;
outline-offset: none !important;
}
The website can be seen here. Note: you will be redirected if viewing from a browser (need to be in Dev Tools mobile)
Website
I have just made this little UI at the top of the screen but would like to know how I can prevent the marked text from overflowing. I have tried the overflow:hidden property but that hasn't helped. Any help would be appreciated. The CSS element in question is ward_caption which is in the ward_no.css file
ward_no.jsx
import React, { useState } from "react";
import './ward_no.css';
import { IoMdArrowDropdown } from 'react-icons/io';
import { GoTriangleUp } from 'react-icons/go';
import wardData from '../../../json_data/ward.json';
const WardNo = () => {
const [open, setOpen] = useState(false);
const [ward, setWard] = useState(null);
const onSelect = (value) => {
setWard(value);
setOpen(!open);
}
return (
<div className="ward_no">
<div className="ward_caption">Ward No</div>
<div className="ward_block">
<div className="ward_dropdown">
<div className="ward_box">
{ward === null ? "Enter Ward Number" : ward}
</div>
<div className="ward_dropIcon" onClick={() => setOpen(prev => !prev)}>
{open ? <GoTriangleUp size={"25px"} /> : <IoMdArrowDropdown size={"30px"} />}
</div>
</div>
<div className={open ? "ward_option" : "ward_option_block"}>
{wardData.map((number) => <div className="ward_options" onClick={() => onSelect(number?.wardNo)}>
{number.wardNo}
</div>
)}
</div>
</div>
</div>
);
}
export default WardNo;
ward_no.css
.ward_no {
display: flex;
width: 100%;
height: auto;
}
.ward_caption {
flex: 1;
font-size: 30px;
/* overflow: hidden; */
font-weight: bold;
font-family: Georgia, 'Times New Roman', Times, serif;
margin-right: 20px;
}
.ward_block {
display: block;
flex: 3;
}
.ward_dropdown {
display: flex;
background-color: white;
height: 40px;
border-radius: 10px;
border: 2px solid black;
box-shadow: 1px 2px 4px 1px gray;
}
.ward_box {
display: flex;
/* flex-wrap: nowrap; */
justify-content: flex-start;
align-items: center;
flex: 4;
margin-right: 10px;
padding-left: 10px;
border-radius: 10px;
color: gray;
}
.ward_dropIcon {
display: flex;
justify-content: center;
align-items: center;
flex: 1;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
}
.ward_option_block {
display: none;
}
.ward_option {
display: block;
width: 100%;
height: 200px;
overflow: hidden;
overflow-y: scroll;
background-color: white;
border-radius: 10px;
border: 2px solid gray;
padding-left: 5px;
}
This component gets rendered from the main_screen.jsx file along with two other components placed side by side.
main_screen.jsx
import React from "react";
import './main_screen.css';
// import District from "../widgets/dropdowns/district/district";
import SearchBox from "../widgets/dropdowns/district/search_box";
import WardNo from "../widgets/dropdowns/ward_no/ward_no";
import Category from "../widgets/dropdowns/category/category";
const MainScreen = () => {
return (
<div className="mainScreen">
<div className="filterSearch">
<div className="disctrictDropdown">
<SearchBox></SearchBox>
</div>
<div className="wardNoDropdown"> //This is the component
<WardNo></WardNo>
</div>
<div className="categoryDropdown">
<Category></Category>
</div>
</div>
<div className="searchButton">
Search
</div>
</div>
);
}
export default MainScreen;
main_screen.css
.mainScreen, body {
background-color: white;
}
.mainScreen {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.filterSearch {
display: flex;
width: 100%;
flex-direction: row;
margin-top: 50px;
}
.disctrictDropdown {
flex: 1;
margin-left: 20px;
}
.wardNoDropdown { //This is the wardNoDropdown component
flex: 1;
margin-left: 20px;
}
.categoryDropdown {
flex: 1;
margin-right: 20px;
margin-left: 20px;
}
.searchButton {
display: flex;
justify-content: center;
align-items: center;
width: 150px;
height: 40px;
background-color: lightskyblue;
border-radius: 20px;
box-shadow: 1px 2px 4px 1px gray;
margin-top: 10px;
}
Two ways, which I know could work:
Try to add flex-direction: column; attribute to the display: flex container
This way it will make the text with those input fields ‚listed‘ underneath each other, which looks (for my preference) better
Add white-space: nowrap; to your text div
I'm trying to make a fixed sidebar nav in react but it is overlapping my pages. All my information will be underneath the navbar when I resize my browser. Attached are the pictures. Does anyone know the issue? Thanks. enter image description here
Before browser is resized
After resizing browser
jsx code
function Navbar() {const [currentTab, changeTab] = useState("Home");
return (
<>
<div className='navbar'>
<nav className='nav-menu'>
<ul className='nav-menu-items'>
<li className='nav-text'> Home</li>
<li className='nav-text' >Exexution</li>
<li className='nav-text'>review</li>
<li className='nav-text'>profile</li>
<li className='nav-text'>setting</li>
</ul>
</nav>
</div>
</>
);
}
export default Navbar;
css code
.navbar{
background-color: transparent;
height: 80px;
display: flex;
justify-content: start;
align-items: center;
padding: 0 0 0 0 ;
}
.menu-bars{
margin-left: 2rem;
font-size: 2rem;
background: none;
}
.nav-menu{
background-color: aqua;
width: 250px;
height: 100vh;
display: flex;
justify-content: center;
position: fixed;
top: 0;
}
.nav-menu-item{
width: 100%;
}
.nav-text{
display: flex;
justify-content: start;
align-items: center;
padding: 8px 0px 8px 16px;
list-style: none;
height: 60px;
}
app.jsx
function DefaultContainer() {
return (
<>
<Router>
<Navbar />
<Switch>
<Route path="/" exact component={Home} />
<Route path="/execution" exact component={Execution} />
<Route path="/review" exact component={Review} />
<Route path="/profile" exact component={Profile} />
</Switch>
</Router>
</>
);
}
export default App;
Hello I am having trouble leaving my content at the center of this div
code :
https://codesandbox.io/s/hungry-https-c5432
I tried to put the inline display on h5 and it still didn't work
<div className="App">
<Menu
className="borderless"
style={{ width: "240px", height: "100vh" }}
vertical
>
<Menu.Item className="logo">
<Image src={logo} style={{ width: "50px", height: "50px" }} />
<h5>E M A S A</h5>
<Divider style={{ color: "#000 !important" }} />
</Menu.Item>
</Menu>
</div>
css:
.ui.menu {
border-radius: 0px !important;
border: 0px !important;
box-shadow: none !important;
background-color: #252631 !important;
}
.ui.menu .item {
padding: 8px !important;
}
r {
margin-bottom: 0 !important;
}r {
margin-bottom: 0 !important;
}
In order to align the img to center you can add
margin: 0 auto;
display: block;
and for aligning the text h5 you can add
text-align: center;
Check this link: https://codesandbox.io/embed/sweet-glitter-9toif?fontsize=14&hidenavigation=1&theme=dark
i understood you need them on the same line so add this to the css .ui.vertical.menu .item{display:flex;
justify-content:center;}
You need to update CSS, Here is the demo link
JSX Code
<Menu
className="borderless"
style={{ width: "240px", height: "100vh" }}
vertical>
<Menu.Item className="logo">
<h5>
<Image
src={logo}
style={{ width: "50px", height: "50px", marginRight: "10px" }}
/>
<span>E M A S A</span>
</h5>
<Divider style={{ color: "#000 !important" }} />
</Menu.Item>
</Menu>
CSS
.ui.menu {
border-radius: 0px !important;
border: 0px !important;
box-shadow: none !important;
background-color: #252631 !important;
}
.ui.menu .item {
padding: 8px !important;
text-align: center;
}
.ui.menu .item h5 {
text-align: center;
}
.ui.divider {
margin-bottom: 0 !important;
}
img.ui.image {
display: inline-block;
}
// jsx in React.js
<Table>
<StyledTableBody>
{tradeInData.map(dataRow => {
return (
<FlexTableRow key={dataRow.productId}>
<StyledTableCell style={{flex : "3 1 auto !important"}}>
<ProductNameDiv>
<p>{dataRow.productName} ({dataRow.quantity})</p>
{showDeleteIcon && <DeleteOutline
style={{ cursor : "pointer" }}
/>}
</ProductNameDiv>
<SecondaryText>Id: {dataRow.productId}</SecondaryText>
</StyledTableCell>
<StyledTableCell style={{flex : "1 1 auto !important"}}
>{dataRow.price}</StyledTableCell>
</FlexTableRow>
)}
)}
</StyledTableBody>
</Table>
I want the flexbox on FlexTableRow to show the 2 elements below it at a 3:1 size ratio. You can see it's about 9:1 right now.
Looks like the flexbox on ProductNameDiv is consuming all the space. I can't set it to display: inline-block since it is also a flexbox.
I tried inline-block on the SecondaryText div and that seemed to overwrite the auto margins anyways.
What is the solution to this that will 1) preserve horizontal centering of text, 2) display the 2 children of FlexTableRow at roughly 3:1 horizontally?
// styled components
const StyledTableBody = styled(TableBody)`
* {
text-align: center;
}
`;
const FlexTableRow = styled(TableRow)`
display: flex;
> * {
border: 2px solid goldenrod !important;
}
`;
const StyledTableCell = styled(TableCell)`
border: 1px solid rgba(200, 200, 200, .6);
border-radius: 4px;
padding: 0 !important;
margin: 0 !important;
`;
const ProductNameDiv = styled.div`
border: 2px dashed lightgreen;
display: flex;
justify-content: center;
align-items: center;
`;
const SecondaryText = styled.p`
display: inline-block;
border: 2px dotted lightcoral;
font-style: italic;
font-size: .9rem;
margin: -12px auto 0 auto;
`;
As I was recreating the issue in a Codepen I found that Material UI's table elements caused the issue. I simply replaced them with standard HTML elements and the inner flexbox no longer fought against its own flex-grow setting:
const ReviewTable = styled.table`
max-width: 100vw;
`;
const FlexTableRow = styled.tr`
border: 1px solid rgba(200, 200, 200, .6);
display: flex;
flex-flow: row nowrap;
justify-content: center;
align-items: center;
`;
const StyledTableCell = styled.td`
border-radius: 4px;
padding: 0 !important;
margin: 0 !important;
display: flex;
flex-flow: column nowrap;
justify-content: center;
align-items: center;
`;
const ProductInfoCell = styled(StyledTableCell)`
flex-grow: 3;
`;
const ProductPriceCell = styled(StyledTableCell)`
flex-grow: 1;
margin: 0 auto;
padding: 5px 0 !important;
`;