Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8165135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:28:07+00:00 2026-06-06T19:28:07+00:00

I think it is a fairly simple problem, but I just cant wrap my

  • 0

I think it is a fairly simple problem, but I just cant wrap my head around it and I am not too great with jQuery. I have a div inside of an . The articles height is variable depending on the content (Its a blog post, so some are short, some are long). I want my div to match the height of the article it is nested in.

HTML:

    <article class="PostHome">
    <div class="ColorBarLeft"></div>
        <header>
            <h3>@Html.DisplayFor(modelItem => item.Title)</h3>
            <small>@Html.DisplayFor(modelItem => item.DateCreated)</small>
        </header>

        <section id="PostContent">
            @Html.DisplayFor(modelItem => item.Content)
        </section>

        <section id ="PostTags">
            @Html.Label("Tags:")
            @Html.DisplayFor(modelItem => item.Tags)
        </section>

        @Html.ActionLink("View Full Post", "Post", new { blogTitle = item.Title.Replace(" ", "-"), id = item.Id}, null)
    </article>

And then I tried some jQuery like so:

$(document).ready(function () {
$(".ColorBarLeft").height(function () {
    var height = $(this).height()
    $('.PostHome').height(height);
})
});

I think that code is correct, but it could be off, again, not very good at jQuery.

And I don’t know if this is important but there are going to be multiple posthomes and ColorBarlefts on the page at a time.

***EDIT, changes id=PostHome to class=PostHome

enter image description here

I want the bar where the red squiggly box is.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T19:28:08+00:00Added an answer on June 6, 2026 at 7:28 pm

    An alternative is to add the color bar as a bg image to the article, rather than by adding a div. And if needed, give the article left padding equal to the width of the color bar.

    Another option is to have the div act as a wrapper around all of the content inside the article, and add the color bar (bg image and optional left padding) to the div.

    In both cases, the bg image will be applied to an element that’s naturally guaranteed to have the correct height, without any assistance from jQuery. This is especially useful if the content is likely to change in height while the page is open, as it doesn’t require updating the height using jQuery.

    Edit:

    I think the only CSS-only solution (that doesn’t require jQuery/JavaScript) is if the article is in a separate container from the content above and below, with all 3 containers separately horizontally centered in the page. In that case, the container for the article could have a bg image on the left, and then the article could be given a fixed width and horizontally centered. This avoids the needs for jQuery, doesn’t require absolute positioning (which would take the content out of the flow of the layout), and doesn’t require updating the height if the content changes while the page is open.

    Otherwise, it’s back to square one and just finding the right jQuery code to set the appropriate height for the color bar div. Just be sure to reapply the height if the article content dynamically changes.

    $('.ColorBarLeft').height($('.PostHome').height());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have fairly simple problem but I can not think of the simple solution.
I have what I think should be a fairly simple mapping issue, but not
I have what I think should be a fairly simple implementation, but I'm running
I am trying to do something I think should be fairly simple, but I
I have recently been stuck on what I think should be a fairly simple
My problem in fairly simple. I have a login system constructed using php, mysql
I think this has to be a very simple question but I am not
This seems like another fairly simple thing to do, but I'm again struggling on
I think the title is fairly self explanatory, but to give a little context.
I think what I want to do is a fairly common task but I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.