Я создаю страницу в ответ на показ цены. Итак, я создал элемент Card, чтобы поместить все данные внутрь, а затем использовать его повторно.
На данный момент это выглядит так: \
Please do not pay attention to the red background, I am just using it to easily see UI placement.
I am trying to get this :
To do so, I have created a class PriceCard
as below:
import React from 'react';
import { Button } from 'react-bootstrap';
import TextContents from '../../assets/translations/TextContents';
import './PriceCard.css';
class PriceCard extends React.Component {
render() {
let savingMessage;
if(this.props.buttontext === TextContents.BuyCreditsBtn){
savingMessage = {TextContents.SubscribeAndSave} {this.props.percent}{TextContents.Percent}
}
return(
{this.props.price} {this.props.credits} {TextContents.Credits} {this.props.desc} {this. props.buttontext} {saveMessage} ); }} экспорт PriceCard по умолчанию;
и css это:
.price-card-container {
width: 300px;
height: 420px;
background-color: #ffffff;
box-shadow: 0px 8px 18px 0 rgba(0,0,0,0.14);
border-radius: 30px;
text-align: center;
}
.price-card-container:hover {
width: 330px;
height: 462px;
background-color: #14cff0;
transition: linear;
}
.price-card-container h4 {
font-family: Source Sans Pro;
font-size: 34px;
font-weight: bold;
font-stretch: normal;
font-style: normal;
line-height: 0.8;
letter-spacing: normal;
text-align: left;
color: #14cff0;
}
.price-card-container:hover h4{
color: #ffffff;
}
.price-card-container h5 {
font-family: Source Sans Pro;
font-size: 28px;
font-weight: bold;
font-stretch: normal;
font-style: normal;
line-height: 0.8;
letter-spacing: normal;
text-align: left;
color: #333333;
}
.price-card-container:hover h7{
color: #09778b;
}
.price-card-container h6 {
font-family: Source Sans Pro;
font-size: 10px;
font-weight: 600;
font-stretch: normal;
font-style: normal;
line-height: normal;
letter-spacing: normal;
text-align: center;
color: #14cff0;
}
.price-card-container:hover h6{
color: #ffffff;
}
.price-card-container p {
font-family: Source Sans Pro;
font-size: 14px;
font-weight: normal;
font-stretch: normal;
font-style: normal;
line-height: 1.68;
letter-spacing: normal;
text-align: left;
color: #616161;
}
.price-card-container:hover p{
color: white;
}
.price-card-container:hover .price-card-blue-button {
border-radius: 21px;
border-style: solid;
font-size: 16px;
font-weight: bold;
text-align: center;
color: #14cff0;
box-shadow: 0px 8px 18px 0 rgba(0,0,0,0.14);
padding-top: 5px;
padding-bottom: 7px;
padding-left: 20px;
padding-right: 20px;
background-color: #ffffff;
border-color: #ffffff;
font-family: Source Sans Pro;
}
.price-card-blue-button {
border-radius: 21px;
border-style: solid;
font-size: 16px;
font-weight: bold;
text-align: center;
color: #ffffffff;
box-shadow: 0px 8px 18px 0 rgba(0,0,0,0.14);
padding-top: 5px;
padding-bottom: 7px;
padding-left: 20px;
padding-right: 20px;
background-color: #14cff0;
border-color: #14cff0;
font-family: Source Sans Pro;
}
.price-card-blue-button:focus {
outline: none;
box-shadow: 0px 8px 18px 0 rgba(0,0,0,0.14);
}
.price-card-blue-button:active {
box-shadow: 0px 8px 18px 0 rgba(0,0,0,0.14);
transform: translateY(4px);
}
.price-card-container:hover .price-card-blue-button {
border-radius: 21px;
border-style: solid;
font-size: 16px;
font-weight: bold;
text-align: center;
color: #14cff0;
box-shadow: 0px 8px 18px 0 rgba(0,0,0,0.14);
padding-top: 5px;
padding-bottom: 7px;
padding-left: 20px;
padding-right: 20px;
background-color: #ffffff;
border-color: #ffffff;
font-family: Source Sans Pro;
}
Затем я включаю его в свою страницу, как показано ниже:
import React from 'react';
import PriceCard from '../components/materialdesign/PriceCard';
import { Col, Row} from 'react-bootstrap';
import PriceInfo from '../config/PriceInfo';
import TextContents from '../assets/translations/TextContents';
import './HowItWorks.css';
class HowItWorks extends React.Component {
render() {
const CreditBundles =
<div className="hiw-price-info-container">
<PriceCard desc={TextContents.TextDescHiw1} price={PriceInfo.Credits1.values.price} credits={PriceInfo.Credits1.values.credits} percent={PriceInfo.Credits1.values.percentage} buttontext={TextContents.BuyCreditsBtn}/>
<PriceCard desc={TextContents.TextDescHiw2} price={PriceInfo.Credits2.values.price} credits={PriceInfo.Credits2.values.credits} percent={PriceInfo.Credits2.values.percentage} buttontext={TextContents.BuyCreditsBtn}/>
<PriceCard desc={TextContents.TextDescHiw2} price={PriceInfo.Credits3.values.price} credits={PriceInfo.Credits3.values.credits} percent={PriceInfo.Credits3.values.percentage} buttontext={TextContents.BuyCreditsBtn}/>
</div>
const Subscription =
<div>
<PriceCard desc={TextContents.TextDescHiw1} price={PriceInfo.Subscription1.values.price} credits={PriceInfo.Subscription1.values.credits} buttontext={TextContents.SubscribeBtn}/>
<PriceCard desc={TextContents.TextDescHiw1}price={PriceInfo.Subscription2.values.price} credits={PriceInfo.Subscription2.values.credits} buttontext={TextContents.SubscribeBtn}/>
<PriceCard desc={TextContents.TextDescHiw1} price={PriceInfo.Subscription3.values.price} credits={PriceInfo.Subscription3.values.credits} buttontext={TextContents.SubscribeBtn}/>
</div>
return (
<div className="hiw-container">
<h1> {TextContents.HowItWorksTitle} </h1>
<p> {TextContents.VillagePassport} </p>
{CreditBundles}
</div>
);
}
}
export default HowItWorks;
и css
.hiw-container {
margin-left: auto;
margin-right: auto;
margin-top: 5rem;
margin-bottom:5rem;
width: 70%;
}
.hiw-container h1{
font-family: Fredoka One;
font-size: 50px;
font-weight: normal;
font-stretch: normal;
font-style: normal;
line-height: 1;
letter-spacing: normal;
text-align: center;
color: #333333;
margin-bottom: 3rem;
}
.hiw-container h2{
font-family: Fredoka One;
font-size: 40px;
font-weight: normal;
font-stretch: normal;
font-style: normal;
line-height: 0.58;
letter-spacing: -0.8px;
text-align: center;
color: #333333;
margin-bottom: 2rem;
margin-top: 5rem;
}
.hiw-container p{
font-family: Source Sans Pro;
font-size: 20px;
font-weight: normal;
font-stretch: normal;
font-style: normal;
line-height: 1.6;
letter-spacing: normal;
text-align: center;
color: #616161;
}
.hiw-price-info-container {
display: flex;
flex-direction: row;
background-color: red;
}
/* tablet, ipad version (change font-size here if needed)*/
@media (min-width: 768px) and (max-width: 1024px){
.hiw-container {
margin-left: auto;
margin-right: auto;
margin-bottom:5rem;
width: 50%;
}
}
/* mobile version (change font-size here if needed)*/
@media (max-width: 600px) {
.hiw-container {
margin-left: auto;
margin-right: auto;
margin-bottom:5rem;
width: 70%;
}
}
Я пытаюсь понять, как установить фиксированное расстояние между каждой карточкой, убедиться, что они находятся в центре экрана и имеют плавный или линейный переход при наведении курсора на плитку.
Мекамизм для «преобразования» стиля плитки при наведении курсора выполнен и работает, у меня просто проблема с общим размещением.
Есть идеи, как сделать так, чтобы он выглядел как дизайн? Было бы здорово также иметь переход между defaukt и hove, чтобы изменение выглядело так, как будто это