Box with decorative borders that adjust to different screen sizes

I need help creating a box with border lines separating different sections. After the H2 heading, I want a new border line followed by a paragraph. However, when I try using border-bottom:1px solid, the line does not reach the edges of the main border. Here is an image for reference: image

Here is my code:

<div class="col-sm-8 col-sm-offset-2" id="house">
  <h3 class="text">Our house packages include:</h3>

  <ul class="lead text" id="list">
    <li>Standard site costs (based on 500mm fall to site & ‘M’ Class slab)</li>
    <li>Rainwater Tank or connection to recycled water where available.</li>
    <li>Concrete driveway (up to 55sqm)</li>
    <li>Tiled Front Porch</li>
    <li>Internal Floor Coverings</li>
    <li>5+ star gas instantaneous HWS</li>
    <li>Wall & Ceiling insulation</li>
    <li>‘Classic’ range of inclusions</li>
  </ul>
  <img src="images/landing.jpg" alt="landing Image">
  <p class="note">NB. Please note that all packages are subject to developer and/or council and statutory authorities’ approvals.</p>
</div>

CSS

#house {
  border: 1px solid black;
  background:white;
}

#house h3 {
  border-bottom:1px solid;
  font-size:28px;
  font-weight:bold;
  margin:10px;
}

#list {
  font-size:15px;
  margin:15px;
  padding:15px;
  position:relative;
  right:20px;
  text-align:left;
}

#house img {
  width:40%;
  position:relative;
  left:500px;
  bottom:260px;
}

Please help me create border lines after the heading and after the list items as shown in the image provided. It should also be responsive. Thank you!

Answer №1

It seems like there might be a missing div tag in your code which is hindering the debugging process.

Here's an alternative approach to solving the issue:

<style>

    html { 
        background: #EEE;
        width: 100%;
        height: 100%;
        border: 0;
        text-align: center;
        padding: 40px;
        box-sizing: border-box;
        color: #AAA;
        font-family: calibri;
    }

    .box{
        background: #FFF;
        border: 2px solid #DDD;
        width: 80%; /*SPECIFY WIDTH HERE*/
        display: inline-block;
    }

    .heading {
        border-bottom: 2px solid #DDD;
        width: 100%; 
        padding: 20px; 
        text-size: 30px;
        font-size: 30px;
        box-sizing: border-box;
        display: inline-block;
    }

    .content {
        border-bottom: 2px solid #DDD;
        width: 100%;
        padding: 20px; 
        box-sizing: border-box;
        display: inline-block;
    }

    .footer {
        width: 100%;
        padding: 20px; 
        box-sizing: border-box;
        display: inline-block;
    }

    .myList {
        display: inline-block;
        text-align: left;
        padding: 10px;
    }

    li {
        margin: 10px 0;
    }

    .myImg {
        display: inline-block;
        padding: 10px;
    }

    .houseImg {
        width: 300px;

    }

</style>

    <div class='box'>
        <div class='heading'>
        Our house packages include:
        </div>

        <div class='content'>
            <div class='myList'>
                 <ul class="lead text" id="list">
                    <li>Standard site costs (based on 500mm fall to site & 'M' Class slab)</li>
                    <li>Rainwater Tank or connection to recycled water where available.</li>
                    <li>Concrete driveway (up to 55sqm)</li>
                    <li>Tiled Front Porch</li>
                    <li> Internal Floor Coverings</li>
                    <li> 5+ star gas instantaneous HWS</li>
                    <li>Wall & Ceiling insulation</li>
                    <li>'Classic' range of inclusions</li>
                </ul>
            </div>
            <div class='myImg'>
                <img src='http://www.simplyeleganthomedesigns.com/hudson%20cottage%20FL.jpg' class='houseImg'>
            </div>
        </div>
        <div class='footer'>
            Some Footer text here
        </div>
    </div>

Answer №2

The issue with the h3 element not displaying as expected is due to the application of a margin: 10px;. This particular style rule creates a space of 10px around all sides of the h3 border, causing it to be pushed away from its parent element. To resolve this, simply remove the margin property and the border-bottom will function correctly.

Consider adding borders to all elements in order to visually comprehend how each CSS property impacts the layout of an element's box.

For more details, refer to the box model concept.

Explore W3C Box Model

Discover MDN Box Model

Answer №3

1- There seems to be some spacing inside the border rather than outside of it, as shown in this image. Consider using padding for h3 elements.

padding: 20px;

I have also corrected the list for you. Check it out on jsfiddle.

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

Steps for transforming responseText into JSON format:

After making an XMLHttpRequest, I have received the following JSON response: { "results" : [ { "address_components" : [ { "long_name" : "45", "short_name" : "45", "types" : [ "stre ...

How to disable a select list in HTML using vue.js when it is checked

I need assistance with a form that includes an "age" field. There are two possible scenarios: if the "unknown" box is checked, then the user should not be able to enter/select an age (the option should be disabled). If the box is unchecked, then the user s ...

How come my counter is still at 0 even though I incremented it within the loop?

Within my HTML file, the code snippet below is present: <div id="userCount" class="number count-to" data-from="0" data-to="" data-speed="1000" data-fresh-interval="20"></div> In my Ja ...

There is a lack of definition for an HTML form element in JavaScript

Encountering an issue with a HTML form that has 4 text inputs, where submitting it to a Javascript function results in the first 3 inputs working correctly, but the fourth being undefined. Highlighted code snippet: The HTML section: <form action="inse ...

Unable to change Bootstrap variables within a Next.js project

I'm having trouble changing the primary color in Bootstrap within my NextJS project. I've tried different methods but nothing seems to work as expected. Here is the code snippet from my "globals.scss" file that I imported in "_app.js": $primary: ...

Guide to verifying a value within a JSON object in Ionic 2

Is there a way to check the value of "no_cover" in thumbnail[0] and replace it with asset/sss.jpg in order to display on the listpage? I have attempted to include <img src="{{item.LINKS.thumbnail[0]}}"> in Listpage.html, but it only shows the thumbna ...

Toastr service experiencing issues on Internet Explorer browser

While implementing toastr notifications in my Angular application, I encountered an issue with compatibility across browsers. Specifically, the ngx-toastr module functions properly in Chrome and Firefox, but not in Internet Explorer. Interestingly, it wo ...

Comparison of Angular 2 Load Times on Desktop and Mobile Devices

I'm currently working on a webpage using Angular CLI and bootstrap version 4. I'm facing an issue specifically with the load times when accessed on mobile devices. Interestingly, the page loads in less than a second on desktop but takes over 10 s ...

Struggling to display the inline navbar

For the past few hours (a little over 3 hours, to be exact), I've been grappling with an issue that seems fairly simple. Despite scouring through various SO posts and other resources, I just can't seem to figure out the problem. The crux of the ...

Is there a way to make the text scroll up automatically when it overflows?

I have a straightforward div element that occupies the header's height but currently has a fixed height of 400px for testing purposes. Here is how it currently appears: https://i.sstatic.net/gg6kQ.png I am utilizing the type-it library to dynamical ...

What could be causing the sporadic functionality of my jQuery image resizing code?

Seeking help for an issue I am facing with my jQuery code. I have been trying to scale a group of images proportionally within an image carousel using jCarousel Lite plugin. However, the resizing code seems to work randomly and I can't figure out why. ...

Inheriting Internet Explorer's zoom level within the WPF web browser control

My WPF window hosts a web browser control for displaying html/css pages, but I'm running into issues with the zoom factor from Internet Explorer. The web browser control seems to be affected by IE's zoom level, causing distortion in the way my HT ...

Challenges between Django and VSCode

As I dive into practicing website development with Django, I've encountered a problem while trying to save my work in VSCode and updating my local browser. It seems that only certain changes are being reflected. For example, when I delete code in my C ...

Highlighting the parent menu item when hovering over a dropdown menu option to show it is active

I have been searching for a solution to my issue, but none of the suggestions seem to work for me. The problem I am facing is with a menu dropdown in the What's On section of a website I am currently developing. Specifically, I am trying to keep the ...

Tips for achieving content-width while employing the 'grid' display property?

Here is a specific container I am working with: #containerDiv { display: 'grid' grid-template-columns: 'repeat(6, auto)' } The issue I am facing is that the children within the container are taking up more space than their actual w ...

Are the methods of implementing a modal in JavaScript, HTML, and CSS similar to those in Electron JS?

Struggling to implement a button that triggers a modal display using JavaScript? The HTML and CSS components are set up correctly, but the JavaScript functionality seems to be causing issues. Is it possible that Electron JS differs from traditional JavaScr ...

Is it possible to eliminate jagged edges in CSS 2D rasterization by applying anti-aliasing to subpixels?

It appears that the HTML/CSS engine automatically rounds values to the nearest whole px unit. It would be interesting to see non-discrete sizing options (floats). A closer look reveals that in Chrome, widths/heights are rounded to the nearest physical pix ...

Enhance user experience with HTML-tags in tooltips

Is there a way to display a tooltip in Twitter Bootstrap that includes HTML tags for formatting? Currently, I am using the following code: <a class="my-tooltip" rel="tooltip" href="#" data-original-title="CPR + O<sub>2</sub>.">First-Aid ...

Exploring the Potential of CSS Styling within Vue.js

I am in the process of creating a website and I am looking for a way to manage my styles through Vue. I want to be able to utilize CSS with Vue, as the style of .skill-bar serves as the background of the bar, while .skill-bar-fill represents the green fil ...

Transforming the hue of a Bootstrap button

I'm feeling a bit frustrated because I expected my code to work and shouldn't have to ask this question. Currently, I am working with bootstrap and trying to customize the default blue color of the btn btn-primary class to something different. ...