Is there a way to reduce the height of the border-left property in CSS?

In creating a simple address panel, I have divided it into three sections: address, phone number, and email. Each section includes an icon and a paragraph next to it. To align these sections side by side, I used the vertical-align: top and display: table properties. Additionally, I added a border-left property to the main div containing all the sections. My goal is to design the layout in such a way that the line passes through the icons without extending beyond the top and bottom of each icon.

Here is the HTML part:

<div class="row">
            <div class="col-md-6 col-sm-12">
                <h2 class="heading-title">Drop in our office</h2>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
                <div class="address-top">
                    <div class="address-repeat">
                        <div class="address-left">
                            <div class="body-widget">
                                <i class="fa fa-map-marker" aria-hidden="true"></i>
                            </div>
                        </div>
                        <div class="address-right">
                            <div class="body-widget">
                                <label>ADDRESS</label>
                                <p>Huatai Securities (USA)10 Hudson Yards 41FlNY, NY 10001</p>
                            </div>
                        </div>
                    </div>
                    <div class="address-repeat">
                        <div class="address-left">
                            <div class="body-widget">
                                <i class="fa fa-phone" aria-hidden="true"></i>
                            </div>
                        </div>
                        <div class="address-right">
                            <div class="body-widget">
                                <label>LETS TALK</label>
                                <p>212-763-8166</p>
                            </div>
                        </div>
                    </div>
                    <div class="address-repeat">
                        <div class="address-left">
                            <div class="body-widget">
                                <i class="fa fa-envelope" aria-hidden="true"></i>
                            </div>
                        </div>
                        <div class="address-right">
                            <div class="body-widget">
                                <label>GENERAL SUPPORT</label>
                                <p><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c6a4a9a7b4a2a9a0a0afa5a386aeb2b5a5e8a5a9ab">[email protected]</a></p>
                            </div>
                        </div>
                    </div>
                </div>  
            </div>

Here is the CSS part:

.address-left, .address-right{
    vertical-align: top;
    height: 100%;
    display: table-cell;
}
.address-left{
    width:50px;
    box-sizing: border-box;
    padding: 20px 0 0 0;
}
.address-right{
    width: 200px;
    max-width: 100%;
    box-sizing: border-box;
    padding: 25px 0 0 0;
}
.address-repeat{
    width: 100%;
    margin: 20px 0 0 -12px;
}

.address-top{
    width: 100%;
    border-left:2px solid #d5d5d5;
    margin: 20px 0 0 10px;
}

#contact-us .address-right p{
    color:#5e5e5e;
    font-family: 'Montserrat-Regular';
    padding: 0;
    margin: 0;
    letter-spacing: 0.5px;
    font-size:14px;
    width:200px;
    font-weight: lighter;
}
#contact-us label{
    font-family: 'HelveticaNeueLTStd-HvCn';
    font-size:17px;
    color:#343434;
}
#contact-us i{
    color:#ffffff;
    font-size: 15px;
    border-radius:50%;
    width:25px;
    height:25px;
    line-height:23px;
    padding:1px 0 0 6px;
    background-color:#e70020;
}

Answer №1

Instead of using a left border, you can achieve the same effect by utilizing the ::before pseudo-element in your CSS code:

.address-left, .address-right{
    vertical-align: top;
    height: 100%;
    display: table-cell;
}
.address-left{
    width:50px;
    box-sizing: border-box;
    padding: 20px 0 0 0;
}
.address-right{
    width: 200px;
    max-width: 100%;
    box-sizing: border-box;
    padding: 25px 0 0 0;
}
.address-repeat{
    width: 100%;
    margin: 20px 0 0 -12px;
}

.address-top{
    width: 100%;
    margin: 20px 0 0 10px;
    position:relative;
}

.address-top::before {
  position: absolute;
  left: 0;
  top: 25px;
  height: calc(100% - 50px);
  width: 2px;
  content: '';
  background-color: #d5d5d5;
  z-index: -1;
}

#contact-us .address-right p{
    color:#5e5e5e;
    font-family: 'Montserrat-Regular';
    padding: 0;
    margin: 0;
    letter-spacing: 0.5px;
    font-size:14px;
    width:200px;
    font-weight: lighter;
}
#contact-us label{
    font-family: 'HelveticaNeueLTStd-HvCn';
    font-size:17px;
    color:#343434;
}
#contact-us i{
    color:#ffffff;
    font-size: 15px;
    border-radius:50%;
    width:25px;
    height:25px;
    line-height:23px;
    padding:1px 0 0 6px;
    background-color:#e70020;
}
<div class="row">
  <div class="col-md-6 col-sm-12">
    <h2 class="heading-title">Visit Our Office</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    <div class="address-top">
      <div class="address-repeat">
        <div class="address-left">
          <div class="body-widget">
            <i class="fa fa-map-marker" aria-hidden="true"></i>
          </div>
        </div>
        <div class="address-right">
          <div class="body-widget">
            <label>ADDRESS</label>
            <p>123 Some Street, City, Country Zip Code</p>
          </div>
        </div>
      </div>
      <div class="address-repeat">
        <div class="address-left">
          <div class="body-widget">
            <i class="fa fa-phone" aria-hidden="true"></i>
          </div>
        </div>
        <div class="address-right">
          <div class="body-widget">
            <label>CONTACT US</label>
            <p>555-555-5555</p>
          </div>
        </div>
      </div>
      <div class="address-repeat">
        <div class="address-left">
          <div class="body-widget">
            <i class="fa fa-envelope" aria-hidden="true"></i>
          </div>
        </div>
        <div class="address-right">
          <div class="body-widget">
            <label>GENERAL SUPPORT</label>
            <p><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a6c4c9c7d4c2c9c0c0cfc5c3e6ced2d5c588c5c9cb">[email protected]</a></p>
          </div>
        </div>
      </div>
    </div>  
  </div>
</div>

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

Achieving functionality with dropdown menus in jQuery

I am facing an issue with a dropdown menu that works perfectly in jsFiddle during testing, but does not function as expected when I run it on my testing server. jsFiddle: http://jsfiddle.net/cyberjo50/39bu8/2/ HTML <!doctype html> <html> < ...

The HTML element in the side menu is not adjusting its size to fit the parent content

Update: What a day! Forgot to save my work... Here is the functioning example. Thank you for any assistance. I have set up a demo here of the issue I'm facing. I am utilizing this menu as the foundation for a page I am developing. The menu is built ...

"Creating a new page dynamically by populating it with a variable that was set on the previous page

I am a beginner in PHP and currently working on creating a website to showcase information about TV shows stored in a MySQL database. My current progress includes a webpage that generates a table to display the data from the database. However, my goal is t ...

As soon as I hover over my icon to enlarge it, I notice that my entire page starts to

Whenever I hover over my icon, the font size increases causing the div to expand slightly and move the page. This doesn't look great. How can I prevent the div from resizing when hovering over the icon? Here's my code: <div className="bg- ...

Align the div in the center horizontally

Looking at this page, my goal is to center the main #container div horizontally in relation to the page. In a typical scenario, I would simply add a CSS rule like this, #container { margin: 0 auto } However, the layout of this specific page (which I didn ...

Multiple CSS styles are being employed simultaneously to render the webpage

Currently, I am utilizing JavaScript to choose different CSS styles for various accessibility options such as black on white text and larger text. The issue I am facing arises when switching the CSS sheet, as elements from previously selected sheets are st ...

How can I prevent the <br/> tag from being included on every new line when exporting data to PDF in jQuery Datatable?

I am currently working with a datatable that contains a large amount of data. Within this table, I have included 2 buttons for exporting the data in PDF and CSV formats. One of the columns within my table contains a comma-separated string, and when I expor ...

Create a modal dialog in CSS that dynamically adjusts its size without extending beyond the edges of the screen

I'm in the midst of developing a web application specifically for tablets. My goal is to display a modal dialog with a title bar and body that dynamically adjusts in height based on its content. If the content exceeds the viewport size, I want the dia ...

A new URL must be refreshed for the link to properly bind the data received from the API call with the subscribe method

In my Angular application, I have a URL link that fetches data from the backend API using the subscribe method in a component. The expected behavior is that when this URL is accessed in a browser, the data should be displayed in the corresponding HTML comp ...

Form-linked Progress Bar

This is a little project I created (for fun and learning purposes, even though it may not be the most optimized solution). If you're interested, here's the link to the code: https://codepen.io/paschos/pen/xxGXMQb I'm currently seeking assi ...

Methods to Maintain Consistent HTML Table Dimensions utilizing DOM

I am facing an issue with shuffling a table that contains images. The table has 4 columns and 2 rows. To shuffle the table, I use the following code: function sortTable() { // Conveniently getting the parent table let table = document.getElementById("i ...

Modifying text size using JavaScript string manipulation

I'm currently experimenting with a countdown script, but I'm struggling to change the size of the numbers displayed. Can anyone help me find where I can adjust the font and font size in this script? var eventdate = new Date("February 20, 2014 11 ...

Guide on integrating a dynamic element within another element in Angular

Imagine a scenario where we have the following html structure <div [innerHTML]="contentFromAPI | safeHTML"></div> The content retrieved from the api contains multiple HTML elements, resulting in a structure like this: <div> &l ...

Ways to turn off hover highlighting

Is there a way to disable the highlighting effect of the <select> element in HTML? When you hover over items in the dropdown list, a blue color strip moves with your mouse. I need to find a way to get rid of this effect. Here is an example of the c ...

Is it possible to repeatedly activate a function using onmousedown just like with onkeydown?

My goal is to have the onmousedown event trigger repeatedly when the left mouse button is held down, instead of just once upon clicking. Currently, it only fires a single time. wHandle.onmousedown = function (event) { console.log('mouse b ...

Creating an event on the containing element

Here is my HTML tag: <ul> <li> <form>...</form> <div> <div class="A"></div> <div class="B"><img class="wantToShow"></div> </div> ...

Encountering difficulties in running bootstrap on nodejs

As a beginner in node.js and bootstrap, I am eager to create my own personal website, so I found some tutorials to help me get started. After downloading bootstrap 2.0.2 and unzipping it, I organized the files by placing bootstrap and bootstrap-responsive ...

Is it achievable to dynamically modify the style URL in an Angular component based on certain conditions?

element: I am working with two different CSS files, one for Arabic layout and one for English layout. I am wondering if it is possible to conditionally change the style URL in the component. Is this feasible? ...

Tips for utilizing the grid system in Bootstrap 4 to transform a dropdown menu into the desired shape shown in the image

I am struggling to create a dropdown menu similar to the one highlighted with a red border in the image, The screenshot I referenced is from the bootswatch website (a bootstrap theme). Although I attempted to use bootstrap flex utility, I was unable to a ...

Utilizing Jquery tabs for consistent height display

Currently, I am utilizing jquery tabs for showcasing various content. This is what my functions look like: $(function() { $( "#tabs" ).tabs(); }); I attempted to ensure all tabs have the same height by using this approach: var heightStyle = ...