Slanted border dividing columns in hero slideshow

Currently in the process of designing my app's landing page. I have a sketch that I would like to replicate: https://i.sstatic.net/6swcE.jpg

The round border around "OR" is optional, but I am more concerned with the oblique line at the moment.

Is there a way to achieve this effect using CSS or any other method?

So far, I have created the hero section, column layout, and slider with owlCarousel. However, I am struggling with creating the oblique line. I have tried adjusting tutorials to suit my needs, but haven't been successful.


    <div class="hc-item row w-100 p-0 m-0">
        <div class="col-md-5 left-column">
            <div class="content">
                <h2 class="text-center">Lorem ipsum dolor.</h2>
                <button class="btn btn-outline-warning d-flex mx-auto">View more</button>
            </div>
        </div>
        
        <div class="col-md-2 my-auto divider-column">
            <h2 class="text-center">OR</h2>
        </div>
        
        <div class="col-md-5 right-column">
            <div class="content">
                <h2 class="text-center">Lorem ipsum dolor.</h2>
                <button class="btn btn-outline-warning d-flex mx-auto">View more</button>
            </div>
        </div>
    </div>

.hc-item {
    min-height: 100vh;
    height: 100vh;
    background: wheat;
}

.left-column {
    background-image: url('https://images.pexels.com/photos/6021588/pexels-photo-6021588.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940');
}

.right-column {
   background-image: url('https://images.pexels.com/photos/33041/antelope-canyon-lower-canyon-arizona.jpg?auto=compress&cs=tinysrgb&h=650&w=940');
}

.left-column .content {
    position: absolute;
    top: 5%;
    left: 10%;
}

.right-column .content {
    position: absolute;
    bottom: 5%;
    right: 10%;
}

.left-column,
.right-column {
    overflow: hidden;
    margin: 0;
    padding: 0;
    object-fit: cover;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;    
}

To see what I've completed so far, view this jsfiddle: https://jsfiddle.net/8sLaqjb1/

I'm unsure how to create the oblique border as well as adjust the images' width to fit the oblique shape (I assume different widths will be needed for the top and bottom).

Answer №1

I had some fun experimenting with your Fiddle, it presented an interesting challenge. What I managed to do may not be flawless, but it's a good starting point.

Within the HTML structure, I removed the col-md-2 my-auto classes from the .divider-column div. Additionally, I rearranged the .content divs as siblings of the skewed images.

A significant portion of my changes were applied to your CSS, particularly focusing on utilizing transform: skew() and transform: translate().

$(document).ready(function() {
    var owl;
    owl = $('.home-carousel').owlCarousel({
        loop: true,
        margin: 0,
        nav: false,
        dots: false,
        autoplay: true,
        autoplayTimeout: 7500,
        smartSpeed: 750,
        items: 1
    });
    
    // Reset timer on action
    owl.on('changed.owl.carousel', function(e) {
        owl.trigger('stop.owl.autoplay');
        owl.trigger('play.owl.autoplay');
    });
});
body {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    background-color: #121212;
    color: #FFFFFF;
    min-height: 200vh;
}

.hc-item {
    min-height: 100vh;
    height: 100vh;
    background: black /*wheat;*/ /* CHANGED */
}

.left-column {
    background-image: url('https://images.pexels.com/photos/6021588/pexels-photo-6021588.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940');
    
    /* ADDED */
    transform: skew(0,-40deg) translateY(-150vh);
    height: 200vh;
}

.right-column {
    background-image: url('https://images.pexels.com/photos/33041/antelope-canyon-lower-canyon-arizona.jpg?auto=compress&cs=tinysrgb&h=650&w=940');
    
    /* ADDED */
    transform: skew(0,-40deg) translateY(-150vh) translateY(6px);
    height: 200vh;
}

/* CHANGED */
.left-content {
    position: fixed;
    top: 13vh;
    left: 4%;
}

/* CHANGED */
.right-content {
    position: fixed;
    bottom: 10vh;
    right: 2%;
}

.left-column, .right-column {
    overflow: hidden;
    margin: 0;
    padding: 0;
    object-fit: cover;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;    
}

/* ADDED */
.divider-column h2{
  position: absolute;
  z-index: 10;
  box-sizing: border-box;
  top: calc(50vh - 1rem - 8px - 0.3em);
  left: calc(50vw - 1rem - 8px - 0.3em);
  border-radius: 100%;
  border: 4px solid black;
  padding: 0.3em;
  background: white;
}
<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8>;
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>trIP Records</title>;

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.3/css/bootstrap.min.css" integrity="sha512-oc9+XSs1H243/FRN9Rw62Fn8EtxjEYWHXRvjS43YtueEewbS6ObfXcJNyohjHqVKFPoXXUxwc+q1K7Dee6vv9g==" crossorigin="anonymous" />

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.min.css" integrity="sha512-sMXtMNL1zRzolHYKEujM2AqCLUR9F2C4/05cdbxjjLSRvMQIciEPCQZo++nk7go3BtSuK9kfa/s+a4f4i5pLkw==" crossorigin="anonymous" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css" integrity="sha512-tS3S5qG0BlhnQROyJXvNjeEM4UpMXHrQfTGmbQ1gKmelCxlSEBUaxhRBj/EFTzpbP4RVSrpEikbmdJobCvhE3g==" crossorigin="anonymous" />
  </head>

  <body>

    <section>
      <div class="owl-carousel owl-theme home-carousel">

        <div class="hc-item row w-100 p-0 m-0">
          <div class="col-md-5 left-column"></div>
          <div class="left-content">
            <h2 class="text-center">Lorem ipsum dolor.</h2>
            <button class="btn btn-outline-warning d-flex mx-auto">View more</button>
          </div>

          <div class="divider-column">
            <h2 class="text-center">OR</h2>
          </div>

          <div class="col-md-5 right-column"></div>
          <div class="right-content">
            <h2 class="text-center">Lorem ipsum dolor.</h2>
            <button class="btn btn-outline-warning d-flex mx-auto">View more</button>
          </div>
        </div>

      </div>
    </section>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.3/js/bootstrap.min.js" integrity="sha512-8qmis31OQi6hIRgvkht0s6mCOittjMa9GMqtK9hes5iEQBQE/Ca6yGE5FsW36vyipGoWQswBj/QBm2JR086Rkw==" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js" integrity="sha512-bPs7Ae6pVvhOSiIcyUClR7/q2OAsRiovw4vAkX+zJbw3ShAeeqezq50RIIcIURq7Oa20rW2n2q+fyXBNcU9lrw==" crossorigin="anonymous"></script>
  </body>

</html>

The outcome in the provided snippet is decent... It would be most beneficial to view the Fiddle and experiment with resizing...

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

Tips on changing the outline color by clicking

I'm working on a simple code where I need to change the outline color when a user clicks on a text field. <input type="text" id="box1" /> <input type="password" id="box2" /> <input type="email" id="box3" /> <input type="submit" ...

Formatting of XML in IE10 is not retained when displayed within an iframe

I'm in the process of creating a basic HTML file and looking to include an XML file within it. My method for doing this involves using iFrames. Surprisingly, when I view the XML file in IE9, it appears formatted (despite some activeX warnings). Howeve ...

Having trouble getting this JavaScript query to function properly

The initial div in the code snippet below showcases the name of a university. When this name is clicked, it activates the function display_people(). This function is responsible for displaying or hiding the individuals associated with that university. The ...

Is there a reason why the slide up feature is not working when I include the ul tag?

I need help with a jQuery code that will pull up/slide up an Html "p" tag when my page finishes loading. This snippet of jQuery code seems to be working fine: $(function () { $('.graybgc').slideUp(0); }); This is the HTML structure: <p ...

It is not possible for ReactJS to disable a button that has been created dynamically

Incorporating ReactJS, I dynamically generate a form using customized JSON data. render() { return ( <div> <ShowForm src={this.state.data} /> </div> ); } After updating with componentDidUp ...

Changing up the grid with alternating colors

I am looking to create a two-column grid layout with alternating colors for the grid blocks. However, using just nth-child(odd) or nth-child(even) won't give me the desired outcome. I believe I can achieve this by utilizing some clever nth-child tech ...

Is there a way to link a SQLite local database with an HTML frontend?

After transitioning my basic database from Ms Access to SQLite for the sake of having an open source option, I am now challenged with developing a visual data entry form for this database. A similar query (HTML/JS as interface to local SQLite database) ou ...

Changing a div's properties is causing jQuery to behave strangely

Something strange happened while coding in javascript, especially with some jquery functions. Check out my code below <?php // Encoded in UTF-8 if(isset($_SESSION['username'])) { ?> <script type="text/javascript"> funct ...

Creating a 2-column CSS layout with the navigation column stopping before reaching the bottom of the page

Creating a 2 column CSS layout may seem simple based on what is taught in class, but the reality can be quite different. The textbook explains how to make the Nav column float left, however, it doesn't always extend all the way down the page as illust ...

Using Tailwind CSS's width property w-11/12 actually returns a full 100% width instead of the expected 91.66

It seems that the w-11/12 class is not behaving as expected. According to the documentation, it should give a width of 91.666% but instead, it's filling up 100%. This issue only occurs with the value 11, while other values work fine. Has anyone else e ...

Issue with deploying responsive background image on Github platform

My responsive background image isn't displaying properly on mobile devices after I deployed my project to Github. Although it appears correctly under the Google Chrome inspect mobile tool, when accessed live on a mobile device, the image covers the ba ...

Adding a hyperlink to each table cell (td) in HTML and CSS that is visible outside of the table

In my table, there is a link on every td. I want these links to appear outside the table. Although I have achieved this, the first cell that was created needs to be hidden. When I try to hide the td using CSS, the link also disappears. Here is the HTML: ...

Is it possible to create a Bootstrap 4 Modal using JQuery and AJAX?

Currently, I have a form enclosed within a modal, and I am struggling to extract the data from the modal for use in other parts of my application. Despite attempting to follow JQuery and AJAX tutorials to handle the data, I have been unsuccessful in getti ...

Incorporate dynamic HTML into Angular by adding CSS styling

Just starting out with Angular and have limited front-end experience. I'm feeling a bit lost on how to proceed. Currently, I have a mat-table with a static datasource (will connect to a database in the future), and I need to dynamically change the bac ...

The click event on a card is not triggering on a cloned item in the Owl Carousel 2

I have implemented owl carousel to showcase products, where each product is displayed on a card with an 'add to cart' button. However, I am facing an issue where the 'add to cart' button on a cloned item does not trigger the click event ...

``Enhance your website with stunning Bootstrap 4 image cards that beautifully showcase

I'm having trouble creating 3 simple image cards with captions in Bootstrap 4. No matter what I do, the image keeps taking up the entire card and covering the caption below it. My cards should look similar to Bootstrap's example card, using the ...

Ways to move an element beyond specified padding using CSS

In this image below, I have added a 10px padding to the container as it is usually needed. However, for the headings (blue) I do not want any padding. Is there a way to make the heading extend over the padding? https://i.sstatic.net/DeSHZ.jpg I prefer no ...

Ensuring that your content spans the entire viewport is crucial for optimizing

https://gyazo.com/1440b13007c6e011ec46218ceecabb6a Upon examining the screenshot, it is evident that there is a white border surrounding the main content of the page. Despite my attempts to adjust everything to 100% width, I have not been success ...

Achieving a smooth sliding motion with the help of jQuery animation

Here is the code snippet: In HTML: <div> <div id="div1">12345</div> <div id="div2">67890</div> <div id="div3"><a href="#" id="slide">abcde</a></div> <div id="pad" style="display:non ...

How can I apply a CSS filter to achieve a blue-toned effect on an image?

Is there a way to change the color of an image to "bluescale" or "greenscale," similar to using filters in CSS? Or is it possible to use a combination of filters for this effect? filter:grayscale(100%); Thank you! I found a solution, but it may not be ...