Creating shapes with CSS and Vue

I've been attempting to replicate this design on my website using CSS and Vue, but I'm struggling to achieve the desired result. As a newcomer to this, I could really use some guidance.

Here is my goal:

https://i.sstatic.net/WI9Wr.png

This is what I have managed to create so far:

https://i.sstatic.net/iVDkF.png

I haven't quite nailed the look of the first image. Any tips on how I can improve it?

<div id="parallelogramred" class="shape"></div>
  <div id="parallelogramwhite" class="shape">
    <a class="">Sign In</a>
    <img style="float:left;" src="./assets/scss/images/loginLogo.png" class="imgLogin">
  </div>

Here's my CSS:

.imgLogin{
          width: 20px;
        }

        .shape{
          display: inline-block;
          margin: 16px;
        }

        #parallelogramred {
           width: 150px; 
           height: 50px; 
           background: red;
           -webkit-transform: skew(-30deg); 
           -moz-transform: skew(-20deg); 
           -o-transform: skew(-20deg); 
           padding-top: 0px;
        }
        #parallelogramwhite {
           width: 150px; 
           height: 50px; 
           background: white;
           -webkit-transform: skew(-30deg); 
           -moz-transform: skew(-20deg); 
           -o-transform: skew(-20deg); 
           padding-top: 0px;
        }

Answer №1

To implement this effect, you can utilize the pseudo-class :before. Below is a sample code snippet demonstrating how it can be utilized:

body {
  background: url(https://www.example.com/image.jpg) no-repeat;
  background-size: cover;
  margin: 0;
}

#banner {
  width: 380px;
  height: 55px;
  position: relative;
  overflow: visible;
  margin: 0 0 0 auto;
  background: #fff;
}

#banner:before {
  content: '';
  display: block;
  z-index: 1;
  position: absolute;
  top: 0;
  left: -30px;
  background: red;
  transform: skew(-45deg);
  height: 100%;
  width: 30%;
}


#banner .content {
  margin-left: 30%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  position: relative;
  background: transparent;
}
<div id="banner">
   <div class="content">
     Content goes here
   </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

Navigating with a dropdown menu enhanced by parallax scrolling

Currently, I am in the process of creating a website for my organization completely from scratch using Bootstrap and parallax elements. After stumbling upon a demo online, all I aim to do is incorporate a navigation bar with a floating dropdown menu button ...

Switching tabs in an Ionic Vue 3 application can be done seamlessly by navigating from

I recently developed an Ionic Vue 3 tabs starter application where I am attempting to switch tabs programmatically from one tab to another. Here is the scenario: // Code snippet in Tab1.vue page setup(props, context) { function moveToTab3(){ // Nee ...

Is it feasible to achieve this layout using only CSS in Windows Internet Explorer 6?

<div class="article"> <span class="articleTitle"> Welcome to our blog!</span> <span class="articleIcon"></span> </div> I am looking to achieve the following: 1. The max-width of <div class="art ...

Implementing CSS to Style Images in JavaFX FXML

After creating the FXML structure below, I attempted to define a border in CSS for the Image by using code in the customerform.css file: <VBox id="customerFormPane" styleClass="customerForm" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.exampl ...

Guide on utilizing the carousel component in Bootstrap and populating it with data generated from Node.js

My goal is to design a carousel that displays 5 different pieces of information pulled from a separate app.js file. I attempted to implement a forEach loop, but encountered issues when trying to create a second Bootstrap carousel container. Here's th ...

Tips for incorporating Action Links into your CSS workflow

<li class="rtsLI" id="Summary"><a href="javascript:void(0);" onclick="javascript:rtsXXX.OnClientTabSelected(this‌​, 0);" class="rtsLink"><span class="rtsTxt">Test</span></a></li> I have made a change by replacing th ...

PHP script, creating a public function that manipulates an array while also incorporating CSS styles

Within a public function, I have the following PHP: [ 'type' => 'text', 'desc' => $this->l('some information'), ] Using this code will show the text "some information" on a webpage. Is there a way ...

Dynamic computed subcomponents in Vue.js are a powerful way to create flexible

Currently, I am facing a scenario where I need to create computed local subcomponents. Specifically, I am working on custom data grid row cell components. Here is an example of what I am trying to achieve: var DataGridRow = { props: ['columns&ap ...

JQuery UI - Issue with Draggable functionality immediately after dropping it

HTML: <div class="character_list"> <div id="draggable" class="character_list_container"> <div><img class="1" src="http://ahna.web44.net//img/charas/13.png" /></div> <div><img class="2" src="http://a ...

Tips on succeeding in managing components: Laravel and Vue components

I find myself in a situation where I have two components named App.vue and ModalComponents, and I need to pass the fetchUser function from App.vue to ModalComponents. Does anyone know how I can accomplish this task? Here is the code snippet from App.vue: ...

Separate Vue Js component data, methods, and props into individual TypeScript files

For my project, I am using Vue JS 2 along with TypeScript. In order to achieve this, I need to import data.ts, methods.ts, and props.ts into my customComponent.vue file: <!-- ////////////////////////////////////////////////////////////////////// --> ...

Hide the background when the modal appears

I have successfully implemented a jQuery CustomBox modal on my website. However, I am facing an issue with hiding the content div behind the modal once it pops up. My goal is to make the content div reappear after the modal has been closed. You can view a ...

In my Ionic/Angular project, I'm attempting to showcase two columns side by side in a row. However, the layout seems to be stacking them on top of each other with the

I am having some trouble arranging two columns in a row for my Ionic/Angular project. It seems like the content is stacking on top of each other instead of side by side. Here's the CSS I'm using: <ion-grid class="rewards-container&q ...

Simple 3-column grid design in HTML and CSS

My task is to design a 3-grid layout that resembles the following structure: ------------------------------------- | Image | The name of logo | > | ------------------------------------- I attempted this using the code below: <div class=" ...

Creating a dynamic background using a blend of two hues in CSS

Is there a way to stack two colors on top of each other using just one div element, or even better, achieve the same effect with just one color that is a blend of the two? I currently have two divs superimposed, with the top one at 60% opacity. I've ...

Utilizing Vue and routes to streamline communication between components

Recently delving into Vue.js, I've hit a roadblock. My goal is to pass information from one component to another through routes. For example, when navigating from 'teacher' to 'student list' and then selecting the first student, i ...

How to Implement Angular Masonry with AngularJS?

I'm working on a layout that utilizes the passsy extension for angular masonry. <masonry column-width="200"> <div class="masonry-brick" ng-repeat="data in comments"> <div ng-switch on="data.type"> <div ng-swit ...

Modify the CSS based on the number of elements present in the Meteor collection

Currently, I am in the process of developing an application that will enable users to save equations and access them from a homepage. The goal is to have a button labeled "Equation" appear on this homepage. However, I am faced with the challenge of styling ...

Send information from a form to a PHP script using axios

I'm having trouble correctly utilizing axios to send form data to a PHP script. Can anyone confirm if the syntax of my axios code is accurate? Additionally, I would like to know how I can verify the data that is being transmitted via the POST method. ...

Here’s a guide on accessing variable values from different JavaScript files in Nuxt.js

In my Nuxt.js project, I organized the file directories as follows: <pre> /* Create a axios instance with custom headers */ import axios from 'axios'; let myVariable = someVariable //someVariable is the result from // asynchronous //r ...