skip to Main Content

Regardless of the number of lines in the title, the paragraph content should always start on the same line. The post info (Clarkson Smiles and the date), title, and content are all in the same container.enter image description here

I am using Elementor Pro, and since it cannot make the content always start on the same line, I tried using CSS.
my code doesnt work. Please help. thanks

.post {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

.post-content {
    flex-grow: 1;
}

Please also see this sample website – https://torontonorthperiodontics.ca/blogs/

2

Answers


  1. Give the minimum height to every title for the two lines. After you use the line clamp for the set, all title and content start for the one line.

    .card-item {
        display: flex;
        column-gap: 20px;
        max-width: 1000px;
        margin: 0 auto;
    }
    
    .card-item .item {
        border: 1px solid;
        padding: 10px 20px;
    }
    
    .card-item .item h3 {
        min-height: 44px;
        display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
          text-overflow: ellipsis;
        overflow: hidden;
    }
    <div class="card-item">
        <div class="item">
            <h3>Lorem ipsum dolor sit amet Lorem ipsum dolor</h3>
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
                quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
                cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
                proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
        </div>
        <div class="item">
            <h3>Lorem ipsum dolor sit amet</h3>
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
                quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
                cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
                proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
        </div>
        <div class="item">
            <h3>Lorem ipsum dolor sit amet Lorem ipsum dolor</h3>
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
                quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
                cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
                proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
        </div>
    </div>
    Login or Signup to reply.
  2. full Code would be nice, but the main issue is overlapping text from title takes control of spacing/ height. thus if you have lets say one word title for one card, and the other card has 25 word title, all of them will be pushed down because of the 25 word title.

    A solution here is to make the height of the title fixed through clamping system — line clamp.

    for example, you make the height of the title fixed to 2 lines. and if the title goes over two lines, you just add an ellipsis at the end to better control.

    .card-item {
        max-width: 1200px;
        margin: 0 auto;
        padding: 20px;
        display: grid;
        gap: 20px;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
    
    .item {
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        padding: 16px;
        background: white;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
    
    .item h3 {
        margin: 0;
        font-size: 1.125rem;
        line-height: 1.5;
        height: calc(1.5em * 2); /* Exactly 2 lines height */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: 16px;
    }
    
    .item p {
        margin: 0;
        font-size: 1rem;
        line-height: 1.5;
        color: #4a5568;
    }
    <body>
        <div class="card-item">
            <div class="item">
                <h3>asdf asdfasdfasdfasdffd asdf afsasdf asdfasdfasdfasdffd asdf afsasdf asdfasdfasdfasdffd asdf afsasdf asdfasdfasdfasdffd asdf afsasdf asdfasdfasdfasdffd asdf afsasdf asdfasdfasdfasdffd asdf afsasdf asdfasdfasdfasdffd asdf afsasdf asdfasdfasdfasdffd asdf afsasdf asdfasdfasdfasdffd asdf afsasdf asdfasdfasdfasdffd asdf afsasdf asdfasdfasdfasdffd asdf afs</h3>
               <p>Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test </p>
            </div>
            <div class="item">
                <h3>asdfasdfadsfas</h3>
                <p>Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test </p>
            </div>
            <div class="item">
                <h3>asdfadsfadasdf asdfadsfadasdf asdfadsfadasdfasdfadsfadasdf asdfadsfadasdf asdfadsfadasdfasdfadsfadasdf asdfadsfadasdf asdfadsfadasdfasdfadsfadasdf asdfadsfadasdf asdfadsfadasdfasdfadsfadasdf asdfadsfadasdf asdfadsfadasdf</h3>
                <p>Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test </p>
            </div>
        </div>
    </body>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search