Ways to style the horizontal div using CSS

I am looking to create a horizontal div using CSS that looks like the one shown in the image below. image reference

Answer №1

You can achieve the desired effect using the following CSS code:

transform: skew();

This will apply a skew transformation to your element in CSS.

Here is a working example:

body {
margin: 0;
}

.intro {
position: relative;
width: 65vw;
height: 100vh;
left: -15vw;
background-color: rgb(47, 47, 47);
transform: skew(-10deg);
}
<div class="intro">
</div>

Answer №2

Is something along these lines what you're looking for? I stumbled upon this quick copy/paste on a website I created.

Check it out here

#sx {
  -webkit-clip-path: polygon(0 0, 95% 0, 74% 100%, 0% 100%);
  clip-path: polygon(0 0, 100% 0, 84% 100%, 0% 100%);
  background-image: url('https://unsplash.it/1920/1080/?random');
  //background-image: url('http://loremflickr.com/1920/1080/dog,cat');
  background-position: center center;
  background-clip: border-box;
  background-repeat: no-repeat;
  background-size: cover !important;
  background-attachment: scroll;
  overflow: scroll;
  width: 50vw !important;
  height: 100vh;
  display: flex;
  align-items: center;
  align-content: center;
  flex-direction: column;
  transition: all 0.5s cubic-bezier(.34, -0.32, .42, 1.34);
  &:hover {
    border: 10px solid white;
    width: 100vw !important;
    -webkit-clip-path: polygon(0 0, 100% 0, 100% 100%, 0% 100%);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0% 100%);
    ~ #dx {
      //width:100vw !important;
    }
    h1 {
      //margin-left: 25vw;
      color: white;
      @include textlongshadow(#222);
    }
    img {
      //margin-left: 25vw;

      @include longshadow();

      //-webkit-filter:drop-shadow(10px 10px 10px white) drop-shadow(20px 20px 10px red);
      //longdrop(20,#222);
    }
  }

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

Execute a jQuery function every time the class of the parent container div changes

I am seeking to trigger the function below whenever its containing div parent <div class="section">...</div> transitions to an "active" state, for example: <div class="section active">...</div> $(".skills-grid__col").each(function ...

Unable to adjust the width of a datatable using the jQuery Datatable plugin version 10.1

I am facing a challenge with multiple datatables using the jQuery plugin on my page. Some of the datatables fit perfectly within the page width, while others extend beyond the page boundaries. Despite trying various methods, including setting styles in HTM ...

Tips for aligning an icon vertically within a span tag

I have a span similar to this: <span class="indicator"></span> Sometimes this span contains numbers like: <span class="indicator"> <span>10</span> </span> Other times it may display Kendo-UI icons, such as: < ...

Creating a customized design for a React application with the use of Scss and JavaScript variables

Is there a method to incorporate JavaScript variables into an SCSS file? For instance, I have a JavaScript file containing the following code: // sky blue const PRIMARY_COLOR = '#489FEF' export { PRIMARY_COLOR} and I would like to utilize it ...

Why aren't my messages showing up once I exit the textbox on my website?

After writing various functions to compare two passwords, I encountered an issue. My goal was for the message "The passwords match" or "Please enter your password again because the two passwords don't match" to be displayed when clicking out of the "v ...

I am looking to transfer the value of one textbox to another textbox within a dynamic creation of textboxes using JavaScript

var room = 1; function add_fields() { room=$('#row_count').val()-1; room++; var objTo = document.getElementById('education_fields'); var divtest = document.createElement("div"); divtest.setAttribute("class", "form- ...

display a list of items in the dashboard using Angular 2 md-sidenav when clicked

I've successfully implemented a sidebar navigation menu in Angular 2, resembling the image shown in the link below: https://i.sstatic.net/KFvJQ.jpg UPDATE: However, I'm facing an issue where clicking on a category link within the sidebar doesn ...

Automatically navigate through form fields using jQuery when pasting data

Enhancing the form filling experience by allowing users to prepare a text file in advance and simply copy/paste it into the form for quick submission. Integration of a feature that automatically moves to the next input field when a tab or newline character ...

Creating a responsive layout with Bootstrap using fluid rows and columns of varying heights

Using dynamic creation, I am tasked with generating a set of boxes each with slightly varying heights and ensuring that 2, 3, or 4 of them (based on screen size) appear on the same row. Here is an example of my attempt using Bootstrap: <div class="cont ...

Attempting to clear out a bootstrap-select element and refill it with new options

I've been attempting to clear all the values in a multiselect selectpicker from bootstrap-select, but unfortunately, no matter what method I try, it doesn't seem to work. I attempted to follow the examples provided for the remove method in the m ...

Bootstrap 4 modal with scrollspy feature for a seamless full-screen experience

I am trying to implement a full-screen modal using Bootstrap 4 that incorporates a scrollspy feature for scrolling the content within the modal body. I have successfully achieved the full-screen aspect, but I am facing issues with making the content scroll ...

Creating dynamic form fields using AngularJS

I have a form that includes an input field, a checkbox, and two buttons - one for adding a new field and one for deleting a field. I want to remove the add button and instead show the next field when the checkbox is checked. How can I achieve this? angu ...

Twitter Bootstrap button group items are being truncated off the edge of the screen

I've encountered an issue with my button dropdown extending beyond the visible page area. I've implemented the standard Bootstrap code for the dropdown: <div class="btn-group"> <button class="btn btn-info">Log In</button> ...

Bootstrap doesn't display in the dropdown menu

Struggling to get a dropdown menu to display on my page, my HTML code is: <div class="dropdown d-inline"> <div class="widget-header mr-3"> <button href="#" class="icon icon-sm rounded-circle border" data-toggle="dropdown"><i cl ...

Tips for implementing a scrolling renderer in ThreeJS?

I'm currently utilizing the OrtographicCamera. Within the HTML, a canvas is declared and then passed to the renderer like this: var canvas = document.getElementById("canvas") var width = canvas.clientWidth; var height = canvas.clientHeight; render ...

What is the best way to retrieve user data and format the output using JavaScript into a structured form?

I am trying to achieve the functionality shown in this image: https://i.sstatic.net/svzvc.png My goal is to extract user input from a form and display it on my webpage using JavaScript. Below is the code snippet that I have been working on. Code: f ...

Integrating C code into an HTML webpage

My C code includes #include <stdio.h> and I want to display it on a webpage using the pre and code tags. However, the angle brackets are disappearing in the output. #include stdio.h Is there a way to show the stdio.h with the angle brackets intac ...

How can you style text with a circular border using CSS?

I'm struggling to locate an example of what I need. My goal is to make a circle around my text using CSS. While I've seen examples of circles with the text inside, in this case, I aim to have a circle surrounding the text. Here's an illustr ...

Arranging components in a horizontal layout on Jquery mobile

I'm completely new to Jquery mobile and I'm having trouble getting these elements aligned. Here's my code, but I need the two icons to line up horizontally with the caption "Heading". <h3>Heading</h3> <img src="../re ...

Avoid Scrolling within an iFrame in HTML with the Use of #

I have a menu loading in an iframe with links using # like http://<location>/page.html#part1. When I click inside the iframe, the entire page outside of the iframe scrolls to the location of #. How can I stop this from happening? I only want the me ...