Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • CSS Tutorial
  • CSS Exercises
  • CSS Interview Questions
  • CSS Selectors
  • CSS Properties
  • CSS Functions
  • CSS Examples
  • CSS Cheat Sheet
  • CSS Templates
  • CSS Frameworks
  • Bootstrap
  • Tailwind
  • CSS Formatter
Open In App
Next Article:
How to make a vertical wavy text line using HTML and CSS ?
Next article icon

How to add lines besides a vertical text using SASS ?

Last Updated : 09 Mar, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

In this article, we will see how to add lines besides some vertical text using SASS.

Approach: The HTML code is used to depict the basic structure of the body. Here, we define a division element with a class of wrapper to contain subsequent division elements. Another division element with a class of vertical-text is defined and it is rotated by 90 degrees using the transform property in SASS. For the rest of the text, two other division elements are defined with classes item-top and item-bottom respectively to represent some other text apart from the vertical text and these division elements are wrapped within another division element with a class of items.

Coming to SASS, to add a line beside the vertical text, we use the border-bottom property since the rotated element’s bottom section is actually displayed as a vertical border. The margins and the paddings of the other division elements are adjusted accordingly since the transform operation takes the vertical text outside of the normal flow of the document.

Example 1: Here, the vertical text is a random date (in this case 27 Feb 2022) and there is a line beside it defined using the border-bottom property (as explained earlier).

style.scss

body {
    text-align: center;
}
  
h1 {
    color: green;
    font-size: 2.5rem;
}
  
p {
    font-size: 1.25rem;
}
  
.wrapper {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    max-width: 600px;
    min-width: 600px;
    margin: 6rem auto 0 auto;
}
  
.vertical-text {
    display: flex;
    transform: rotate(-90deg);
    border-bottom: 2px solid black;
    padding-left: 5.5rem;
  
    p {
        padding-bottom: 0.1rem;
    }
}
  
.items {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    margin-left: -3.8rem;
    margin-top: -3rem;
  
    p {
        padding-left: 1rem;
    }
}
  
.item-top {
    p {
        padding-bottom: 1rem;
    }
}
  
.item-bottom {
    border-top: 2px solid black;
  
    p {
        padding-top: 1rem;
    }
}
                      
                       

Output: The generated CSS output will be as shown below.

style.css

body {
    text-align: center;
}
  
h1 {
    color: green;
    font-size: 2.5rem;
}
  
p {
    font-size: 1.25rem;
}
  
.wrapper {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: start;
    -ms-flex-align: start;
    align-items: flex-start;
    -webkit-box-pack: start;
    -ms-flex-pack: start;
    justify-content: flex-start;
    max-width: 600px;
    min-width: 600px;
    margin: 6rem auto 0 auto;
}
  
.vertical-text {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-transform: rotate(-90deg);
    transform: rotate(-90deg);
    border-bottom: 2px solid black;
    padding-left: 5.5rem;
}
  
.vertical-text p {
    padding-bottom: 0.1rem;
}
  
.items {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-pack: start;
    -ms-flex-pack: start;
    justify-content: flex-start;
    -webkit-box-align: start;
    -ms-flex-align: start;
    align-items: flex-start;
    margin-left: -3.8rem;
    margin-top: -3rem;
}
  
.items p {
    padding-left: 1rem;
}
  
.item-top p {
    padding-bottom: 1rem;
}
  
.item-bottom {
    border-top: 2px solid black;
}
  
.item-bottom p {
    padding-top: 1rem;
}
                      
                       

index.html

<!DOCTYPE html>
<html>
  
<head>
    <!-- jQuery -->
    <script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
    </script>
      
    <!-- Compiled CSS from SASS file -->
    <style>
        body {
            text-align: center;
        }
  
        h1 {
            color: green;
            font-size: 2.5rem;
        }
  
        p {
            font-size: 1.25rem;
        }
  
        .wrapper {
            display: -webkit-box;
            display: -ms-flexbox;
            display: flex;
            -webkit-box-align: start;
            -ms-flex-align: start;
            align-items: flex-start;
            -webkit-box-pack: start;
            -ms-flex-pack: start;
            justify-content: flex-start;
            max-width: 600px;
            min-width: 600px;
            margin: 6rem auto 0 auto;
        }
  
        .vertical-text {
            display: -webkit-box;
            display: -ms-flexbox;
            display: flex;
            -webkit-transform: rotate(-90deg);
            transform: rotate(-90deg);
            border-bottom: 2px solid black;
            padding-left: 5.5rem;
        }
  
        .vertical-text p {
            padding-bottom: 0.1rem;
        }
  
        .items {
            display: -webkit-box;
            display: -ms-flexbox;
            display: flex;
            -webkit-box-orient: vertical;
            -webkit-box-direction: normal;
            -ms-flex-direction: column;
            flex-direction: column;
            -webkit-box-pack: start;
            -ms-flex-pack: start;
            justify-content: flex-start;
            -webkit-box-align: start;
            -ms-flex-align: start;
            align-items: flex-start;
            margin-left: -3.8rem;
            margin-top: -3rem;
        }
  
        .items p {
            padding-left: 1rem;
        }
  
        .item-top p {
            padding-bottom: 1rem;
        }
  
        .item-bottom {
            border-top: 2px solid black;
        }
  
        .item-bottom p {
            padding-top: 1rem;
        }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
    <div class="wrapper">
        <div class="vertical-text">
            <p>27 Feb 2022</p>
        </div>
        <div class="items">
            <div class="item item-top">
                <p>GeeksforGeeks</p>
            </div>
            <div class="item item-bottom">
                <p>GeeksforGeeks is a computer
                   science portal for geeks.</p>
            </div>
        </div>
    </div>
</body>
  
</html>
                      
                       

Output:

Example 2: This example is quite similar to the previous example but the only difference is that there is only one item division element apart from the vertically rotated text. Moreover, the vertical text is rotated the other way around by 90 degrees instead of negative 90 degrees.

style.scss

body {
    text-align: center;
}
  
h1 {
    color: green;
    font-size: 2.5rem;
}
  
p {
    font-size: 1.25rem;
}
  
.wrapper {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    max-width: 600px;
    min-width: 600px;
    margin: 6rem auto 0 auto;
}
  
.vertical-text {
    display: flex;
    transform: rotate(90deg);
    border-top: 2px solid black;
    padding-right: 3rem;
    color: green;
    font-weight: bold;
}
  
.items {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    margin-left: -5.8rem;
    margin-top: -3rem;
  
    p {
        padding-left: 5rem;
    }
}
                      
                       

Output: The generated CSS output will be:

style.css

body {
    text-align: center;
}
  
h1 {
    color: green;
    font-size: 2.5rem;
}
  
p {
    font-size: 1.25rem;
}
  
.wrapper {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: start;
    -ms-flex-align: start;
    align-items: flex-start;
    -webkit-box-pack: start;
    -ms-flex-pack: start;
    justify-content: flex-start;
    max-width: 600px;
    min-width: 600px;
    margin: 6rem auto 0 auto;
}
  
.vertical-text {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-transform: rotate(90deg);
    transform: rotate(90deg);
    border-top: 2px solid black;
    padding-right: 3rem;
    color: green;
    font-weight: bold;
}
  
.items {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-pack: start;
    -ms-flex-pack: start;
    justify-content: flex-start;
    -webkit-box-align: start;
    -ms-flex-align: start;
    align-items: flex-start;
    margin-left: -5.8rem;
    margin-top: -3rem;
}
  
.items p {
    padding-left: 5rem;
}
                      
                       

index.html

<!DOCTYPE html>
<html>
  
<head>
    <!-- jQuery -->
    <script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
    </script>
  
    <!-- Compiled CSS from SASS file -->
    <style>
        body {
            text-align: center;
        }
  
        h1 {
            color: green;
            font-size: 2.5rem;
        }
  
        p {
            font-size: 1.25rem;
        }
  
        .wrapper {
            display: -webkit-box;
            display: -ms-flexbox;
            display: flex;
            -webkit-box-align: start;
            -ms-flex-align: start;
            align-items: flex-start;
            -webkit-box-pack: start;
            -ms-flex-pack: start;
            justify-content: flex-start;
            max-width: 600px;
            min-width: 600px;
            margin: 6rem auto 0 auto;
        }
  
        .vertical-text {
            display: -webkit-box;
            display: -ms-flexbox;
            display: flex;
            -webkit-transform: rotate(90deg);
            transform: rotate(90deg);
            border-top: 2px solid black;
            padding-right: 3rem;
            color: green;
            font-weight: bold;
        }
  
        .items {
            display: -webkit-box;
            display: -ms-flexbox;
            display: flex;
            -webkit-box-orient: vertical;
            -webkit-box-direction: normal;
            -ms-flex-direction: column;
            flex-direction: column;
            -webkit-box-pack: start;
            -ms-flex-pack: start;
            justify-content: flex-start;
            -webkit-box-align: start;
            -ms-flex-align: start;
            align-items: flex-start;
            margin-left: -5.8rem;
            margin-top: -3rem;
        }
  
        .items p {
            padding-left: 5rem;
        }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
    <div class="wrapper">
        <div class="vertical-text">
              
<p>GeeksforGeeks</p>
  
        </div>
        <div class="items">
            <div class="item">
                <p>
                    GeeksforGeeks is a Computer Science
                    portal for geeks. It contains
                    well written, well thought 
                    and well explained computer 
                    science and programming articles.
                </p>
            </div>
        </div>
    </div>
</body>
  
</html>
                      
                       

Output:



Next Article
How to make a vertical wavy text line using HTML and CSS ?

R

rajatsandhu2001
Improve
Article Tags :
  • CSS
  • Geeks Premier League
  • Web Technologies
  • CSS-Questions
  • Geeks-Premier-League-2022
  • HTML-Questions
  • SASS

Similar Reads

  • How to make a vertical wavy text line using HTML and CSS ?
    In this article, a wavy animated text is implemented using HTML and CSS. It is one of the simplest CSS effects. For a beginner, it is one of the best examples to learn the concept of CSS pseudo-elements. Approach: The basic idea of getting wavy texts is performed by using the combination of some CSS
    2 min read
  • How to Vertically Align Text Next to an Image using CSS ?
    Adding images into our websites is a common practice, and there are situations where text must be vertically aligned alongside an image. For example, a user’s name should appear immediately next to their profile picture, vertically aligned for optimal readability . In this article, we will see how t
    2 min read
  • How to Set Vertical Space Between the List of Items using CSS?
    Vertical space refers to the distance between elements arranged vertically on a webpage. In CSS, it can be set between list items using properties like margin or padding etc. These properties help create a visually appealing layout, enhancing readability and organization of the content. Below are th
    4 min read
  • How to Add Shadow to Text using CSS?
    The text-shadow property is used to add shadow to the text. The text-shadow property creates text shadows, specifying horizontal/vertical offsets, blur radius, and color for depth and emphasis. Note: We can customize text shadow by changing position, blur, and color for improved appearance and visua
    1 min read
  • How to Add Text Outline with CSS?
    Since CSS does not provide a direct text-outline property, the CSS text-shadow property is used to create an outline effect around text by adding multiple shadows with offsets. 1. Using text-shadow PropertyThe text-shadow property is commonly used to add shadows to text, by applying multiple shadows
    1 min read
  • How to use a sass variable in nth child class ?
    SASS is one of the most popular CSS extension languages which provides superpower to the normal CSS. The nth-child() class is a pseudo-class, when some HTML element has more than two elements of the same kind then we can use the nth-child class pseudo-class to provide styling to those elements witho
    2 min read
  • How to Vertically Align Text Within a Div in CSS?
    Aligning text vertically within a div can enhance the visual appeal of your web design. There are various approaches to achieving vertical alignment using CSS. 1. Using line-height PropertyThe line-height property is the easiest and most commonly used approach to align text within a div vertically.
    2 min read
  • How to create linear gradient text by using HTML ?
    Creating linear gradient text on a webpage can add a dynamic and visually interesting touch to the design. While it is typically created using CSS, it is also possible to create linear gradient text using only HTML. Approach: Using the `<svg>` Element: The `<svg>` element in HTML provide
    2 min read
  • How to Add Border Around Text using CSS?
    The CSS border property is used to add a border around text by wrapping the text in an HTML element like <span> or <p>. Syntax border: "borderWidth borderStyle colorName;"Example 1: Adding a border around the text content using CSS. [GFGTABS] HTML <p> The following text has a borde
    1 min read
  • How to create linear gradient text using HTML and CSS ?
    The linear-gradient is used to create eye-catching text effects, particularly suitable for dark-themed websites or applications. This method involves filling text with linear-gradient color codes, making it look attractive and bold. Linear-gradient text effects are ideal for dark themes and provide
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences