import React from "react";
export default function Example() {
return (
<div>
<div
className="grid"
style={{
gridTemplateColumns: "1.75rem repeat(288, minmax(0, 1fr)) auto",
}}
>
<div
className="mt-px inline-grid grid-cols-1 sm:col-start-3"
style={{ gridColumn: "74 / span 12" }}
>
<a href="#" className="rounded-lg bg-blue-50 p-2 text-xs">
<p className="order-1 font-semibold text-blue-700">Breakfast</p>
<p className="text-blue-500 group-hover:text-blue-700">
<time dateTime="2022-01-12T06:00">6:00 AM</time>
</p>
</a>
</div>
<div
className="mt-px inline-grid grid-cols-1 sm:col-start-3"
style={{ gridColumn: "76 / span 12" }}
>
<a href="#" className="rounded-lg bg-blue-50 p-2 text-xs">
<p className="order-1 font-semibold text-blue-700">Breakfast</p>
<p className="text-blue-500 group-hover:text-blue-700">
<time dateTime="2022-01-12T06:00">6:30 AM</time>
</p>
</a>
</div>
</div>
</div>
);
}
If you want both the tiles over one another , add absolute w-1/4 right-4 class to both the divs.
import React from "react";
export default function Example() {
return (
<div>
<div
className="grid"
style={{
gridTemplateColumns: "1.75rem repeat(288, minmax(0, 1fr)) auto",
}}
>
<div
className="absolute w-1/4 right-4 mt-px inline-grid grid-cols-1 sm:col-start-3"
style={{ gridColumn: "74 / span 12" }}
>
<a href="#" className="rounded-lg bg-blue-50 p-2 text-xs">
<p className="order-1 font-semibold text-blue-700">Breakfast</p>
<p className="text-blue-500 group-hover:text-blue-700">
<time dateTime="2022-01-12T06:00">6:00 AM</time>
</p>
</a>
</div>
<div
className="absolute w-1/4 right-4 mt-px inline-grid grid-cols-1 sm:col-start-3"
style={{ gridColumn: "76 / span 12" }}
>
<a href="#" className="rounded-lg bg-blue-50 p-2 text-xs">
<p className="order-1 font-semibold text-blue-700">Breakfast</p>
<p className="text-blue-500 group-hover:text-blue-700">
<time dateTime="2022-01-12T06:00">6:30 AM</time>
</p>
</a>
</div>
</div>
</div>
);
}
you can adjust right and width as per your requirement .
Related
So i have built a react component, and there's supposed to be a video background as a cover, but I just cant seem to make it work.
I just puts the video outside of the component. Can anyone help me with this please. Also I'm using Tailwind.
import React from "react";
export default function Example() {
return (
<div className="items-start flex flex-col p-2 h-96 w-fit ">
<div>
<video autoPlay loop muted>
<source src="Assets/img/video/test.mp4" type="video/mp4" />
</video>
<div className="items-center flex ml-2 mt-2">
<div className="flex-shrink-0 group block">
<div className="flex items-center">
<div>
<img
className="inline-block h-9 w-9 rounded-full"
src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"
alt=""
/>
</div>
<div className="ml-3">
<p className="text-sm font-medium text-white">Sermad Alladin</p>
<p className="text-sm font-medium text-gray-50">
Elgiganten • 18 t.
</p>
</div>
</div>
</div>
</div>
<div className="items-end self-end flex mt-64">
<div className="flex">
<p className="font-normal h-12 leading-5 w-40 mr-2">
Amazing customer service, but i wish was better...😉
</p>
</div>
<div className="items-center flex h-7 justify-end mb-1 p-2 bg-primary rounded-tl-xl rounded-bl-xl">
<div className="font-bold mx-2 text-white">87</div>
</div>
</div>
</div>
</div>
);
}
I want to transform the menu to have a smooth transition when it opens, but it's not working for me.
I've also tried using hidden class, but ran into the same problem.
Is there a way to make it open smoothly?
My attempt:
import React from "react";
export default function ModerSideMenu({}) {
const [menu, setMenu] = React.useState({
home: true,
});
return (
<div className="w-64 bg-blue-900 h-full p-4 text-white">
<div className="relative">
<div className="flex flex-row items-center justify-between uppercase font-semibold w-full">
<div className="ml-2 flex-row flex items-center space-x-2">
<i className="fas fa-home" />
<p className="">Home</p>
</div>
<i
className={`transform transition-all ease-out duration-300 select-none fas ${
menu.home ? "fa-angle-up" : "fa-angle-down"
} mr-2`}
onClick={() => setMenu({ ...menu, home: !menu.home })}
/>
</div>
<div
className={`ml-4 mt-2 space-y-1 text-sm transform transition-all ease-out duration-300 z-20 select-none ${
!menu.home ? "-translate-y-full" : "translate-y-0"
}`}
hidden={!menu.home}
>
<p>- Home 1</p>
<p>- Home 2</p>
</div>
</div>
<div className="relative mt-2">
<div className="flex flex-row items-center justify-between uppercase font-semibold w-full">
<div className="ml-2 flex-row flex items-center space-x-2">
<i className="fas fa-home" />
<p className="">Home 2</p>
</div>
<i className="justify-self-end fas fa-angle-down mr-2" />
</div>
<div className="ml-4 mt-2 space-y-1 text-sm">
<p>- Home 3</p>
<p>- Home 4</p>
</div>
</div>
</div>
);
}
I am trying to display single product data by fetching it from the server, but there's an issue while opening the modal. If I map, I get a double modal and a blank black screen. How do I get a single product view?
import React, { useState } from "react";
// Import Swiper React components
import { Swiper, SwiperSlide } from "swiper/react";
import { FreeMode, Navigation, Thumbs } from "swiper";
// Import Swiper styles
import "swiper/css";
import "swiper/css/free-mode";
import "swiper/css/navigation";
import "swiper/css/thumbs";
import { Link } from 'react-router-dom';
import { Rating } from "#mui/material";
const ProductView = ({product}) => {
const { title, hoverImg, img, price, rating,vendorName, salePrice } = product;
const [thumbsSwiper, setThumbsSwiper] = useState(null);
return (
<div style={{backgroundColor:'white',width:'800px',height:'600px',overflow:'scroll'}} className='mx-auto container place-content-center px-12 py-8 justify-center items-center grid lg:grid-cols-2 md:grid-cols-2 grid-cols-1 gap-6 sm:flex-1'>
<div>
<Swiper
style={{
"--swiper-navigation-color": "#fff",
"--swiper-pagination-color": "#fff",
}}
spaceBetween={10}
// navigation={true}
thumbs={{ swiper: thumbsSwiper }}
modules={[FreeMode, Navigation, Thumbs]}
className="mySwiper2"
>
<SwiperSlide>
<img alt="" src={img} />
</SwiperSlide>
<SwiperSlide>
<img alt="" src={hoverImg} />
</SwiperSlide>
<SwiperSlide>
<img alt="" src={img} />
</SwiperSlide>
<SwiperSlide>
<img alt="" src={hoverImg} />
</SwiperSlide>
<SwiperSlide>
<img alt="" src={img} />
</SwiperSlide>
</Swiper>
<Swiper
onSwiper={setThumbsSwiper}
spaceBetween={10}
slidesPerView={4}
freeMode={true}
watchSlidesProgress={true}
modules={[FreeMode, Navigation, Thumbs]}
className="mySwiper"
>
<SwiperSlide>
<img alt="" src={img} />
</SwiperSlide>
<SwiperSlide>
<img alt="" src={hoverImg} />
</SwiperSlide>
<SwiperSlide>
<img alt="" src={img} />
</SwiperSlide>
<SwiperSlide>
<img alt="" src={hoverImg} />
</SwiperSlide>
<SwiperSlide>
<img alt="" src={img} />
</SwiperSlide>
</Swiper>
</div>
<div>
<h2 className='text-3xl mb-2 font-medium'>{title}</h2>
<div className='flex items-center mb-4'>
<div>
<Rating name="half-rating-read" defaultValue={rating} precision={0.5} readOnly />
</div>
<div className="text-xs text-gray-500 ml-3">
(1 Reviews)
</div>
</div>
<div className='space-y-2'>
<p className="p text-gray-800 font-semibold space-x-2">
<span>Availability:</span>
<span className='text-green-600'>In stock</span>
</p>
<p className="space-x-2">
<span className='text-gray-800 font-semibold'>Vendor:</span>
<span className='text-gray-600'>{vendorName}</span>
</p>
<p className="space-x-2">
<span className='text-gray-800 font-semibold'>Category:</span>
<span className='text-gray-600'>Men</span>
</p>
<p className="space-x-2">
<span className='text-gray-800 font-semibold'>SKU:</span>
{/* <span className='text-gray-600 uppercase'>{_id.slice(4,12)}</span> */}
</p>
</div>
<div className="flex items-baseline mb-1 mt-2 space-x-2">
<p className="text-xl text-indigo-500 font-semibold">{salePrice}</p>
<p className="text-sm text-gray-400 line-through">{price}</p>
</div>
<div className="">
<h3 className="text-xl text-gray-800 mb-3 uppercase font-medium ">Color</h3>
<div className="flex gap-2">
{/* Single Color Starts */}
<div className="color-selctor">
<input type="radio" name='color' className='hidden' color='red' id='color-red' />
<label htmlFor="color" className='border border-gray-200 rounded-sm h-5 w-5 cursor-pointer shadow-sm block' style={{ backgroundColor: "red" }}></label>
</div>
<div className="color-selctor">
<input type="radio" name='color' className='hidden' color='red' id='color-red' />
<label htmlFor="color" className='border border-gray-200 rounded-sm h-5 w-5 cursor-pointer shadow-sm block' style={{ backgroundColor: "green" }}></label>
</div>
<div className="color-selctor">
<input type="radio" name='color' className='hidden' color='red' id='color-red' />
<label htmlFor="color" className='border border-gray-200 rounded-sm h-5 w-5 cursor-pointer shadow-sm block' style={{ backgroundColor: "blue" }}></label>
</div>
</div>
</div>
<div className="pt-4 block">
<h3 className="text-xl text-gray-800 mb-3 uppercase font-medium">Size</h3>
<div className="flex item-center gap-2">
{/* single size selector starts */}
<div className="size-selector">
<input type="radio" name='size' className='hidden' id='xs' />
<label htmlFor="size-xs" className='text-xs border border-gray-200 rounded-sm h-6 w-6 flex items-center justify-center cursor-pointer shadow-sm text-gray-600'>
S
</label>
</div>
<div className="size-selector">
<input type="radio" name='size' className='hidden' id='xs' />
<label htmlFor="size-xs" className='text-xs border border-gray-200 rounded-sm h-6 w-6 flex items-center justify-center cursor-pointer shadow-sm text-gray-600'>
M
</label>
</div>
<div className="size-selector">
<input type="radio" name='size' className='hidden' id='xs' />
<label htmlFor="size-xs" className='text-xs border border-gray-200 rounded-sm h-6 w-6 flex items-center justify-center cursor-pointer shadow-sm text-gray-600'>
L
</label>
</div>
<div className="size-selector">
<input type="radio" name='size' className='hidden' id='xs' />
<label htmlFor="size-xs" className='text-xs border border-gray-200 rounded-sm h-6 w-6 flex items-center justify-center cursor-pointer shadow-sm text-gray-600'>
XS
</label>
</div>
</div>
</div>
<div>
<h3 className='text-xl text-gray-800 mb-1'>Quantity</h3>
<div className="flex border border-gray-500 divide-gray-500 text-gray-600 divide-x w-max">
<div className='h-8 w-8 flex items-center justify-center cursor-pointer select-none'>
-
</div>
<div className='h-8 w-8 flex items-center justify-center'>
<input style={{width:'34px',height:'34px'}} type="text" />
</div>
<div className='h-8 w-8 flex items-center justify-center cursor-pointer select-none'>
+
</div>
</div>
</div>
<div className="flex gap-3 border-b border-gray-200 pb-5 mt-6">
<Link to = "/">
<button className='text-center top-5 text-white p-2 bg-indigo-500 border border-indigo-500 hover:bg-transparent hover:text-indigo-500 transition'>
<i className="fa-regular fa-bag-shopping"></i> Add to cart
</button>
</Link>
<Link to = "/">
<button className='text-center top-5 hover:text-white p-2 hover:bg-indigo-500 border border-indigo-500 bg-transparent text-indigo-500 transition'>
<i className="fa-regular fa-heart"></i> Add to Wishlist
</button>
</Link>
</div>
</div>
</div>
);
};
export default ProductView;
In the below code the media query not working. Please help if any mistake I did.
I used paragraph media query the below. When I checked in mobile mode t is not working.
/* eslint-disable react/jsx-no-target-blank /
/ eslint-disable react/no-unescaped-entities */
import React from 'react'
import { DropdownButton, Dropdown } from 'react-bootstrap'
const ProfileInfo = () => {
const paragraph = {
position: 'absolute',
top: '66px',
right: '108px',
'#media screen and (min-width: 610px)': {
position: 'static'
}
}
return (
<div className="container-fluid">
<div className="row clearfix">
<div className="col-md-6 col-sm-12"> </div>
<div className="col-md-6 col-sm-12"> </div>
</div>
<div className="row" style={{ margin: 'auto', width: '50%' }}>
<div className="alert alert-success col-md-12 col-sm-12">
<h5 className="alert-heading">Aktive meldinger</h5>
<p>
Hahahahahhhhhfgdfgf gdfgdfgffgdfggfhgh fgdfgdfgfgfg
</p>
</div>
</div>
<div className="row clearfix">
<div className="col-md-6 col-sm-12">
<div className="card mb-3 shadow-sm p-3 bg-white rounded" >
<h5 className="card-title" style={{ color: '#009540' }}><strong>Profile: </strong> </h5>
<p className="card-text"><strong>Navn: </strong> Bengt Nilsfors</p>
<p className="card-text"><strong>Kontaktinformasjon: </strong> 95833897, nilsfors#gmail.com</p>
<DropdownButton id="dropdown-basic-button" variant="outline-primary"
title="Address">
<Dropdown.Item href="#/action-1">Address1 </Dropdown.Item>
<Dropdown.Item href="#/action-2">Address2</Dropdown.Item>
<Dropdown.Item href="#/action-3">Address3</Dropdown.Item>
</DropdownButton>
<p className="card-text"><strong>Adresse: </strong> Nøkken 7 H0101, 9016 Tromsø</p>
<p className="card-text"><strong>Passord: </strong> ***********</p>
<button className="btn btn-success">Rediger</button>
</div>
</div>
<div className="col-md-6 col-sm-12">
<div className="card mb-3 shadow-sm p-3 bg-white rounded" >
<h5 className="card-title" style={{ color: '#009540' }} ><strong>Nettverksanalyse</strong></h5>
<img className="card-img" variant="top" src="../images/testimg.png" style={{ width: '152px' }} />
<div style= { paragraph }>17:58:55: Henter nettverskinfo...<br/>
18:00:31: Nettverkstatus ok. Ingen feil funnet.</div>
<button className="btn btn-warning mt-2 text-center">See details</button>
</div>
</div>
</div>
<div className="row">
<div className="col-md-4 mt-5 text-center">
<div className="card mb-3 shadow-sm p-3 bg-white rounded" >
<div className="card-body">
<h5 className="card-title" style={{ color: '#009540' }}>Abonnement</h5>
<p className="card-text"><strong>Internett</strong></p>
<p className="card-text">Giga (1000/1000) Kr 699,- per mnd.</p>
Oppgrader
</div>
</div>
</div>
<div className="col-md-4 mt-5 text-center">
<div className="card mb-3 shadow-sm p-3 bg-white rounded">
<div className="card-body">
<h5 className="card-title" style={{ color: '#009540' }}>Faktura</h5>
<ul className="list-group" style= {{ float: 'left' }}>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Mars 2021</a></li>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Desember 2020</a></li>
<li><a className="card-link"href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Februar 2021</a></li>
</ul><ul className="list-group" style={{ float: 'right' }}>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Desember 2020</a></li>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}> November 2020</a></li>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Oktober 2020</a></li>
</ul>
<div style={{ marginTop: '76px' }}> Se alle</div>
</div>
</div>
</div>
<div className="col-md-4 mt-5 text-center">
<div className="card mb-3 shadow-sm p-3 bg-white rounded">
<div className="card-body">
<h5 className="card-title" style={{ color: '#009540' }}>Kontakt oss</h5>
<p className="card-text">Kontakt oss via chat eller telefon 38 99 01 00.</p>
Chat
</div>
</div>
</div>
</div>
</div>
)
}
export default ProfileInfo
t's not the problem with react its with the CSS code. If you apply two rules that collide to the same elements, it will choose the last one that was declared. So put the #media queries to the end of the CSS page. i.e
.footer
.column
.social-column-container
.logo {
width: 100px;
height: auto;
display: inline-block;
margin-left: 50px;
}
#media only screen and (min-width: 900px) {
.footer
.column
.social-column-container
.logo {
display: none;
}
}
Dropdown values not showing in Address section. I used bootstrap 4 code.
I am not getting any error, when I am clicking dropdown it's not showing dropdown values.
I have added bootstrap 4 dropdown on this page but it's not working dropdown.
Please help with this.
Here is the code for review and I am a beginner at the react js. Please help
import React from 'react'
const ProfileInfo = () => {
return (
<div className="container-fluid">
<div className="row clearfix">
<div className="col-md-6 col-sm-12"> </div>
<div className="col-md-6 col-sm-12"> </div>
</div>
<div className="row clearfix">
<div className="col-md-6 col-sm-12">
<div className="card mb-3 shadow-sm p-3 bg-white rounded" >
<h5 className="card-title" style={{ color: '#009540' }}><strong>Profile: </strong> </h5>
<p className="card-text"><strong>Navn: </strong> Bengt Nilsfors</p>
<p className="card-text"><strong>Kontaktinformasjon: </strong> 95833897, nilsfors#gmail.com</p>
<div className="dropdown">
<button className="btn btn-info dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Address
</button>
<div className="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a className="dropdown-item" href="#">Address1</a>
<a className="dropdown-item" href="#">Address2</a>
</div>
</div><br/>
<p className="card-text"><strong>Adresse: </strong> Nøkken 7 H0101, 9016 Tromsø</p>
<p className="card-text"><strong>Passord: </strong> ***********</p>
<button className="btn btn-success">Rediger</button>
</div>
</div>
<div className="col-md-6 col-sm-12">
<div className="card mb-3 shadow-sm p-3 bg-white rounded" >
<h5 className="card-title" style={{ color: '#009540' }} ><strong>Nettverksanalyse</strong></h5>
<img className="card-img" variant="top" src="../images/testimg.png" style={{ width: '152px' }} />
<div style= {{ position: 'absolute', top: '66px', right: '108px' }}>17:58:55: Henter nettverskinfo...<br/>
18:00:31: Nettverkstatus ok. Ingen feil funnet.</div>
<button className="btn btn-warning mt-2 text-center">See details</button>
</div>
</div>
</div>
<div className="row">
<div className="col-md-4 mt-5 text-center">
<div className="card mb-3 shadow-sm p-3 bg-white rounded" >
<div className="card-body">
<h5 className="card-title" style={{ color: '#009540' }}>Abonnement</h5>
<p className="card-text"><strong>Internett</strong></p>
<p className="card-text">Giga (1000/1000) Kr 699,- per mnd.</p>
Oppgrader
</div>
</div>
</div>
<div className="col-md-4 mt-5 text-center">
<div className="card mb-3 shadow-sm p-3 bg-white rounded">
<div className="card-body">
<h5 className="card-title" style={{ color: '#009540' }}>Faktura</h5>
<ul className="list-group" style= {{ float: 'left' }}>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Mars 2021</a></li>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Desember 2020</a></li>
<li><a className="card-link"href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Februar 2021</a></li>
</ul><ul className="list-group" style={{ float: 'right' }}>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Desember 2020</a></li>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}> November 2020</a></li>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Oktober 2020</a></li>
</ul>
<div style={{ marginTop: '76px' }}> Se alle</div>
</div>
</div>
</div>
<div className="col-md-4 mt-5 text-center">
<div className="card mb-3 shadow-sm p-3 bg-white rounded">
<div className="card-body">
<h5 className="card-title" style={{ color: '#009540' }}>Kontakt oss</h5>
<p className="card-text">Kontakt oss via chat eller telefon 38 99 01 00.</p>
Chat
</div>
</div>
</div>
</div>
</div>
)
}
export default ProfileInfo
I think you need to use an html table. Then your code will look like this :
<button className="btn btn-info dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Address
</button>
<ul className="dropdown-menu" aria-labelledby="dropdownMenuButton">
<li><a className="dropdown-item" href="#">Address1</a></li>
<li><a className="dropdown-item" href="#">Address2</a></li>
</ul>
</div>
But with React you have a specific bootstrap components. You should use these components : https://react-bootstrap.github.io/components/dropdowns/