Struggling to navigate styling on React - css

I'm extremely new to this stuff, so please don't judge.
I'm trying to build a website and now I'm at the css part of it. My text is showing up in a different color than what I chose, its in the middle and its supposed to be on the left, I added a Menu icon but that's nowhere to be seen and I've added sections in the menu, also nothing.
I feel like crying.
I'm following an instructional and the code is exactly the same, but its showing up different on my side.
import styled from 'styled-components'
import {Link as LinkR} from 'react-router-dom'
import { findByLabelText } from '#testing-library/dom';
import {Link as LinkS} from 'react-scroll'
export const Nav = styled.nav`
background: #000;
height: 80px;
/*margin-top: -80px; */
display: flex;
justify-content: center;
align-items: center;
font-size: 1rem;
position: sticky;
top: 0;
z-index: 1;
#media screen and (max-width: 960px) {
transition: 0.8s all ease;
}
`
export const NavbarContainer = styled.div`
display: flex;
justify-content: space-between;
height: 80px;
z-index: 1'
width: 100%;
padding: 0 24px;
max-width: 1100px;
`
export const NavLogo = styled(LinkR)`
color: red;
justify-self: flex-start;
cursor: pointer;
font-size: 1.5rem;
display: flex;
align-items: center;
margin-left: 24px;
font-weight: bold;
text-decoration: none;
`;
export const MobileIcon = styled.div`
display:none;
#media screen and (max-width: 768px) {
display: block;
position: absolute;
top: o;
right: 0;
transfrom: translate(-100%, 60%);
font-size: 1.8rem;
cursor: pointer;
color: #000;
}
`
export const NavMenu = styled.ul`
display: flex;
align-itens: center;
list-style: none;
text-align: center;
margin-right: -22px;
#media screen and (max-width: 768px) {
display: none;
}
`
export const NavItem = styled.li`
height: 80px;
`
export const NavLinks = styled (LinkS)`
color: #fff;
display: flex;
align-items: center;
text-decoration: none;
padding: 0 1rem;
height: 100%;
cursor: pointer;
&.active {
border-bottom: 3px solid #01bf71;
}
`

I don't know if it solves your problem, but:
In your code at the NavbarContainer after you set the z-index you have a quote instead of a semicolon.
And also at the NavMenu you wrote align-itens instead of align-items.
If you are using VSCode then install the following extension: vscode-styled-components

Related

How can I make it so the text is all on one line for each of these buttons using CSS?

The NavBar component has a className of "NavBar" and the buttons themselves have a className of "navbar-button".
enter image description here
Here is my existing CSS for the NavBar component and the buttons themselves:
.NavBar {
position: relative;
display: flex;
flex-direction: row;
max-width: max-content;
top: -200px;
left: 1300px;
width: 500px
}
.navbar-button {
/* display: inline; */
padding: 15px;
max-width: fit-content;
margin: 10 px;
border-radius: 50px;
border: none;
font-family: 'Poppins', sans-serif;
font-size: 20px;
background-color: #35b276;
color: white;
}

In my React Project Animation is not working

I am new to React
In my React project I wrote a keyframes in app.js and in this project using styled Components
Section.js
import React from "react";
import styled from "styled-components";
function Section() {
return (
<Wrap>
<ItemText>
<h1>Model S</h1>
<p>Order Online</p>
</ItemText>
<Buttons>
<ButtonGroup>
<LeftButton>Custom Order</LeftButton>
<RightButton>Existing Inventory</RightButton>
</ButtonGroup>
<DownArrow src="/images/down-arrow.svg" />
</Buttons>
</Wrap>
);
}
export default Section;
const Wrap = styled.div`
width: 100vw;
height: 100vh;
background-size: cover;
background-image: url("images/model-s.jpg");
background-repeat: no-repeat;
background-position: center;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
`;
const ItemText = styled.div`
padding: 10vh;
text-align: center;
`;
const LeftButton = styled.div`
cursor: pointer;
background-color: rgba(23, 26, 32, 0.8);
color: white;
height: 40px;
width: 256px;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
border-radius: 100px;
opacity: 0.85;
text-transform: uppercase;
font-size: 12px;
`;
const RightButton = styled(LeftButton)`
cursor: pointer;
`;
const ButtonGroup = styled.div`
display: flex;
padding: 15vh;
`;
const DownArrow = styled.img`
margin-top: 20px;
height: 40px;
animation: animateDown infinte 1.5s;
`;
const Buttons = styled.div``;
App.css
* {
box-sizing: border-box;
font-family: "Rubik", sans-serif;
color: #393c41;
margin: 0;
padding: 0;
}
body {
width: 100%;
}
#keyframes animateDown {
0%,
20%,
50%,
80%,
100% {
transform: translateY(0);
}
40% {
transform: translateY(5px);
}
60% {
transform: translateY(3px);
}
}
Check Arrow Down Component I added a Animation on that.
I checked in Chrome it tell in valid property value on webkit I colud not find the Solution
I needed your Help guys
Thanks in Advance <3

Custom react modal getting hidden behind service card

I'm building info modals for a website on the services page. The services page has 3 cards that have different options, heres that code from the services page.
React JS
<ServicesContainer id='services'>
<ServicesH1>Services</ServicesH1>
<ServicesWrapper>
<ServicesCard>
<ServicesIcon src={Icon1} />
<ServicesH2>Equine Therapy</ServicesH2>
<ServicesP>
Work with horses
</ServicesP>
<Button
to='services'
onClick={openInfoModal}
primary='true'
dark='true'
smooth={true}
duration={500}
spy={true}
exact='true'
offset={-80}
>
modal
</Button>
</ServicesCard>
<ServicesCard>
<ServicesIcon src={Icon2} />
<ServicesH2>Group Therapy</ServicesH2>
<ServicesP>
Group therapy.
</ServicesP>
<InfoModal showInfoModal={showInfoModal} setShowInfoModal={setShowInfoModal}/>
</ServicesCard>
<ServicesCard>
<ServicesIcon src={Icon3} />
<ServicesH2>Individual Therapy</ServicesH2>
<ServicesP>
Individual Therapy.
</ServicesP>
</ServicesCard>
</ServicesWrapper>
</ServicesContainer>
When the modal pops up it's hidden behind the 3rd card, i'm assuming it has something to do with the 3rd card coming after the InfoModal component/ the styling. I've tried setting the z-index to 900, messed with opacity as well with no luck. When I put the InfoModal component under the 3rd card it shows up on the 3rd (far right) column of the page off center which I definitely don't want. I've looked around trying to find a solution by maybe being able to identify the custom InfoModal component as a modal so it shows up in front of everything but was only able to find styled-react-modal, which i tried but it made so many errors about ecma script that I just had to remove it. I'm pretty bad with css but heres the InfoModal styled components code
const Background = styled.div`
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 1);
position: fixed;
display: flex;
justify-content: center;
align-items: center;
z-index: 10;
`;
const ModalWrapper = styled.div`
width: 800px;
height: 500px;
box-shadow: 0 5px 16px rgba(0, 0, 0, 1);
background: #fff;
color: #000;
display: grid;
grid-template-columns: 1fr;
position: relative;
z-index: 10;
border-radius: 10px;
`;
const ModalContent = styled.div`
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
line-height: 1.8;
color: #141414;
p {
margin-bottom: 1rem;
}
button {
padding: 10px 24px;
background: #141414;
color: #fff;
border: none;
}
`;
const CloseModalButton = styled(MdClose)`
cursor: pointer;
position: absolute;
top: 20px;
right: 20px;
width: 32px;
height: 32px;
padding: 0;
z-index: 10;
`;
the services styled components code
import styled from 'styled-components';
export const ServicesContainer = styled.div`
height: 800px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background: #189AC0;
z-index: 1;
#media screen and (max-width: 768px) {
height: 1100px;
}
#media screen and (max-width: 480px) {
height: 1300px;
}
`;
export const ServicesWrapper = styled.div`
max-width: 1000px;
margin: 0 auto;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
align-items: center;
grid-gap: 16px;
padding: 0 50px;
z-index: 1;
#media screen and (max-width: 1000px) {
grid-template-columns: 1fr 1fr;
}
#media screen and (max-width: 768px) {
grid-template-columns: 1fr;
padding: 0 20px;
}
`;
export const ServicesCard = styled.div`
background: #fff;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
border-radius: 10px;
max-height: 340px;
padding: 30px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
transition: all 0.2s ease-in-out;
transform: scale(1.05);
z-index: 0.5;
&:hover {
transform: scale(1.05);
transition: all 0.2s ease-in-out;
cursor: pointer;
}
`;
export const ServicesIcon = styled.img`
height: 160px;
width: 160px;
margin-bottom: 10px;
`;
export const ServicesH1 = styled.h1`
font-size: 2.5rem;
color: #fff;
margin-bottom: 64px;
#media screen and (max-width: 480px) {
font-size: 2rem;
}
`;
export const ServicesH2 = styled.h2`
font-size: 1rem;
margin-bottom: 10px;
`;
export const ServicesP = styled.p`
font-size: 1rem;
text-align: center;
`;
I hope this isn't to much but if anyone is good with styling or react, would appreciate any feedback.

CSS :hover on button not working within already hovered div

I have a div appearing on top of an image when I hover the image itself. The div contains two divs (buttons) that also have a :hover that changes their color and sets the cursor to the pointer.
The issue is the hovering on the button doesn't trigger the hover.
Also, it seems that hovering on the image at the bottom where the btn_container will appear doesn't trigger to first :hover and doesn't make the btn_container appear.
//HTML
<div class="container">
<img src="src">
<div class="btn_container">
<div class=" btn">
<p>Select</p>
</div>
<div class="btn">
<p>Preview</p>
</div>
</div>
//SCSS
.container {
position: relative;
width: 100%;
img {
width: 100%;
height: auto;
}
.btn_container {
position: absolute;
width: 100%;
height: 40px;
background-color: var(--dark-purple-trans);
bottom: 0;
left: 0;
align-items: center;
display: none;
position: absolute;
}
img:hover + .btn_container,
.btn_container > * {
display: flex;
border: none;
text-align: center;
justify-content: space-around;
}
.btn {
padding: 6px 12px;
height: 14px;
background: var(--yellow-medium);
border-radius: 8px;
display: flex;
justify-content: space-evenly;
align-items: center;
color: var(--white);
font-family: roboto;
&:hover {
cursor: pointer;
background: var(--red);
color: var(--white);
}
}
}
Preview, button hovering not working:
If I force the hover on the img using the inspector, the button hovering seems to work:
The problem is in classes img:hover + .btn_container and .btn_container > *.
Here is the updated scss:
.container {
position: relative;
width: 100%;
img {
display: block;
width: 100%;
height: auto;
border: 0;
}
&:hover .btn_container {
display: flex;
}
.btn_container {
position: absolute;
bottom: 0;
left: 0;
display: none;
align-items: center;
justify-content: space-around;
width: 100%;
height: 40px;
text-align: center;
background-color: var(--dark-purple-trans);
border: none;
}
.btn {
display: flex;
align-items: center;
justify-content: space-evenly;
height: 14px;
padding: 6px 12px;
color: var(--white);
font-family: roboto;
background-color: var(--yellow-medium);
border-radius: 8px;
cursor: pointer;
&:hover {
color: var(--white);
background-color: var(--red);
}
}
}
You can view it in action here: Codepen
I tried using opacity instead of display to toggle visibility of the btn_container and added a hover to btn_container and it seemed to work: https://jsfiddle.net/pr8dxe2g/1/
.btn_container {
width: 500px;
height: 100px;
background-color: var(--dark-purple-trans);
bottom: 0;
left: 0;
align-items: center;
opacity: 0;
position: absolute;
}
img:hover + .btn_container,
.btn_container:hover,
.btn_container > * {
display: flex;
opacity: 1;
border: 1px solid blue;
text-align: center;
justify-content: space-around;
}
There may be some issue with your current code with the fact that the the img div has a higher stack-order if the display is set to none initially, however I am not certain so if anyone knows I would like to know why this is the case as well.

React native, how to make a shape

i'm trying to made this in react native,
I tried to had a square and an oval, i tried to have border radius in a singular square, but everytime i cannot reach this result.
This is what i tried, but as i said i don't know how to reach this
export const StyledText = styled.Text`
text-align: center;
font-family: ${FONTS.fontFamily.bold};
font-size: 29px;
color: white;
`;
export const StyledContainer = styled.View`
align-items: center;
justify-content: center;
height: 250px;
`;
export const StyledOval = styled.View`
width: 110%;
height: 150px;
border-radius: 100-5;
border-width: 10;
background-color: red;
border-color: black;
position: absolute;
top: 50;
z-index: 10;
`;
export const StyledSquare = styled.View`
flex: 1;
align-content: center;
justify-content: center;
width: 100%;
height: 100px;
background-color: red;
position: absolute;
top: 0;
z-index: 11;
`;

Resources