Setting child div to match the parent div's height at 100% - here's how!

This is the layout of the page Here's the code snippet:

<div class="newsContent row">
    <div class="newsDate col-md-2">05 August 2014</div>
    <div class="newsSeparator col-md-1">
    </div>
    <div class="newsDescription col-md-7">
        <div class="row">
            some dummy news
            <div class="newsImage"><img alt="news2" src="/Images/News/news2.jpg">
            </div>
        </div>
    </div>
    <div class="newsActions col-md-2">
        <div class="row">
            <div class="col-md-4">
                <button type="button" class="btn btn-default btn-lg edit-content" title="Edit the news" <span class="glyphicon glyphicon-pencil">
                    </span>
                </button>
            </div>
            <div class="col-md-4">
                <button type="button" class="btn btn-default btn-lg delete-content" title="Delete the news">
                    <span class="glyphicon glyphicon-trash"></span>
                </button>
            </div>
        </div>

    </div>
</div>

Notice the green line which corresponds with this part

<div class="newsSeparator col-md-1">
</div>

The class for it is

.newsSeparator
{
    background: url('my_1X1_pixel_image.png');
    background-repeat: repeat-y;
}

However, the line is not repeating. Instead, only a 1px image is displayed instead of the desired green line. How can I make it so that the line repeats along the y-axis and adjusts to the parent div size?

EDIT This question is distinct from that one. In my case, I need the background image to repeat vertically.

Answer №1

To create a more organized layout, consider grouping the news description and image within an <article> element.

You can then apply a border-left to this new container, eliminating the need for empty markup used solely for styling purposes and enhancing the overall semantics of the page.

<article>
    <div class="newsDescription col-md-7">
        <div class="row">
           ...
        </div>
    </div>
    <div class="newsActions col-md-2">
        <div class="row">
           ...
        </div>
    </div>
</article>

For styling in your CSS:

article {
   border-left: 1px green solid;
   padding-left: ...  /* add space between the border and content */
}

Answer №2

To make the height of a child div the same as its parent div, simply use height:inherit.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

"Even as the page scrolls down, the scrollbars stubbornly stay anchored at the

I'm currently working on a webpage that includes a link to an anchor, which should be a straightforward case. The link code looks something like this: <a href="#target">Link</a> And the anchor code looks like this: <a name=" ...

How can I loop the keyframe animation across various elements of an SVG file simultaneously?

After creating an animation using CSS and SVG, I am experiencing different parts of it animating in and out. My goal is to have the animation start from the top once it's finished. There are multiple keyframes involved since I'm animating variou ...

Displaying data from a PHP form

I'm working on a table that is populated with data from my controller. The issue I am facing is that only the first record, in this case Sephen C. Cox, does not redirect me when I click the "add employee" button. For all other records, the button work ...

Display a button with an icon only when in responsive mode using HTML, CSS, and Materialize

Is there a way to hide the text on a button but keep the icon visible when viewing on a mobile device? For instance, if a button displays a face icon from MaterializeCSS along with the text "support", I would like to eliminate the text while still showing ...

Scrolling to the complete height of a div using scrollTop

Experience an automated scroll to the bottom of the div, followed by a smooth upward motion over 5 seconds, all while looping seamlessly. A small issue arises where the code only recognizes the standard height set for the div, not its actual scrollable he ...

What is causing this alert to remain open?

I've been struggling to close the alert within the body section. I've tried various fixes but can't seem to figure it out. Can anyone spot what's wrong here? It's just a practice exercise, but I'd really appreciate some help. ...

What is the method for displaying the word '<head>' within a <p> element in HTML code?

My HTML page contains a simple <p> tag. Within this tag, I am attempting to display some text in the following manner: Insert this code snippet into the website header, between <head> and </head>, to activate the functionality notice. ...

Navigating between two HTML files in an ExpressJS project can be easily achieved by setting up routes

Recently delving into expressjs, I am struggling to navigate between two HTML files within the root folder. My project involves utilizing Bootstrap, AngularJS, and ExpressJS. In the routes directory, I have implemented the following code: var express = r ...

My attempts at creating a column in Bootstrap using push and pull are not successful

My Versatile Code for Different Screen Sizes <div class="col-xs-6 col-lg-2"> <div>A</div> </div> <div class="col-xs-12 col-lg-8 "> <div>B</div> </div> <div class="col-xs-6 col-lg-2"> <di ...

JavaScript Date Validation: Ensuring Proper Dates

I am working with a date string that is in the format of "DD-MM-YYYY" and have successfully validated it using this code: var dateFormat = /(0[1-9]|[12][0-9]|3[01])-(0[1-9]|1[012])-\d{4}/ ; if(!startDate.match(dateFormat)){ alert("'Start Dat ...

Is it possible to implement a feature in Angular and Bootstrap where the toggle menu can be closed by clicking anywhere on the page, rather than just the toggle button

I'm working on an Angular project where I've implemented a navbar component. The navbar is responsive and includes a toggle button that appears when the browser window is resized. This button allows users to hide or display the menus. One issue ...

Detect when a child li element is clicked and then toggle the class of its parent div

I have a div container that contains an unordered list tab menu. By clicking on each tab, the menu content changes correspondingly. The functionality is working well, but I want to alter the background image of the container div based on which li is clicke ...

I have come to realize that in my creation, my method does not function flawlessly as

I'm currently experimenting with creating a simple code using vue.js and d3.js. The goal is to plot some charts within the code, so I am attempting to allocate space for the charts by defining a method('add_svg') and executing the method in ...

The alignment of Bootstrap's Tabs is not centered as expected

I'm having trouble aligning the tab list to the center. The image below shows that it's currently shifted to the left. I've already included the Bootstrap class center-block, but it doesn't seem to be working. Can anyone help me out wit ...

manipulating the position of a slider thumb on an input slider with just vanilla javascript

<td> <div id="fpscount" style="margin-left: 70px; margin-top: -4px; position:absolute;">15</div> <input type="range" name="FPS" min="1" max="60" value="15" id="FPS" class="Slide" onchange="window.status=this.value; Update(this.valu ...

Ways to deselect checkboxes and eliminate validation requirements

Below is the HTML code snippet that I am working with: <div class="form-group"> <div class="input-group"> <label for="daterange-vacancy" class="input-group-addon">Van</label> ...

Utilize ng-repeat to display a series of images, with the first image being placed within a unique div

My challenge lies in displaying product images using ng-repeat, where one image is located in a separate div. Let me share my code and explain what is happening. The API response provides product details and images [{"id_product":"1000","name":"Nikolaus ...

Transitioning the Background Image is a common design technique

After spending hours trying to figure out how to make my background "jumbotron" change images smoothly with a transition, I am still stuck. I have tried both internal scripts and JavaScript, but nothing seems to work. Is there any way to achieve this witho ...

Issue with HTML 5 offline storage cache manifest on mobile devices

I have developed a mobile web app and I would like to be able to use it offline as well. I have tried using a manifest file and it works fine with desktop browsers, but unfortunately not with mobile browsers. Can anyone help me identify the issue? Thank ...

Unfortunately, the input type number does not allow for the removal of decimal points

I need assistance with modifying the HTML code below. I want to remove the decimal point from the input field. Could anyone please provide instructions on how to accomplish this? <input type="number" min="0" step="1" ng-pattern="/^(0|[1-9][0-9]*)$/" ...