<p> тег css не применяется и <div>неправильно размещен внизу - PullRequest
0 голосов
/ 06 августа 2020

Мне удалось почти завершить работу, на которую я смотрел, но остается какое-то странное поведение, которое я не могу объяснить.

вот картина того, что я сделал:

enter image description here

and what I expect:

enter image description here

There is few difference that I am not able to fix.

  • The text below the credits part is not using the proper size font but it's defined in the css but it strangely the font size is applied when hover..

  • The 3 tiles must be also aligned vertically

  • The "button + Subscribe" text must be always at the bottom but when hover it moves

Here is the code of the tile itself:

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: white;
    box-shadow: 0px 8px 18px 0 rgba(0,0,0,0.14);
    border-radius: 30px;
    position: relative;
    margin-left: 10px;
    margin-right: 10px;
    transition: 0.5s;
}

.price-card-container:hover {
    width: 340px;
    height: 460px;
    background-color: #14cff0;
    z-index: 1;

}

.price-card-text-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;
    margin-bottom: 10px;
}

.price-card-container:hover h4{
    color: #09778b;
    font-size: 40px;
    margin-bottom: 12px;
}

.price-card-text-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 h5{
    color: white;
    font-size: 36px;
}

.price-card-text-container h6 {
    font-family: Source Sans Pro;
    font-size: 14px;
    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-text-container p {
  font-family: Source Sans Pro;
  font-size: 16px;
  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 .price-card-text-container p {
    color: white;
    font-size: 16px;

}

.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;
    min-width: 100%;
    margin-top: 10px;
    margin-bottom: 10px;
}


.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;
}

.price-card-text-container {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60%;
    height: 70%;
    max-height: 70%;
    -ms-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
}

.price-card-section-bottom {
    bottom: 0px;
}

На моей веб-странице используется плитка с ценовой картой, как показано ниже:


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;
    justify-content: center;
}

/* 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%;
    }

}

Есть идеи? Спасибо

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...