What is the best way to compress the div and its contained text while still maintaining responsiveness?

When I got home from work, I decided to create a website similar to the attached image. However, I encountered an issue with styling the "TECHNOLOGY" div in the top right corner and making it responsive while staying within the parent div. Additionally, any advice on handling the text below the image that changes size on mobile would be greatly appreciated.

Thank you!

body, html{
    margin: 0 auto;
    padding: 0;
    max-width: 960px;
    align-items: center;
    font-family: 'Lora', serif;
}
/* ****Start Nav******** */
nav ul{
    margin: 5px auto;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    justify-content: center;
}

li a{
    display: flex;
    text-decoration: none;
    text-transform: uppercase;
    padding: 20px 50px;
    align-items: center;
    text-align: center;
    margin: 2px;
    color: white;
    background-color: rgb(34, 101, 169);
}
/* ************* End Nav *************** */
/* ******Start 2nd Row with Title********** */
.name{
    max-width: 960px;
    margin: 20px auto;
    display: flex;
    padding: 0px 40px;
    align-items: center;

}
.title {
    Flex: 0 1 auto;
    font-size: 1.8rem;
    border-right: 1px solid black;
    padding-right: 10px;
    font-weight: 500;
}
.title2{
    padding-left: 10px;
    flex: 1 1 auto;
    font-size: 0.9rem;
    font-weight: 600;
}

.contact{
    margin-left: 0 auto;
    line-height: 3px;
    font-size: 0.7rem;
}
/* ******End 2nd Row with Title********** */
/* ********Start blue box with containers */
.blue {
    position: relative;
    z-index: 0;
    display: flex;
    max-width: 960px;
    margin: 0px 40px;
    height: 53vh;
    background-color: rgb(189, 217, 254);
    color: white;
    align-items: center;
    justify-content: center;
}
.tech{
    padding: 0px 10px;
    border-radius: 5px;
    background-color: rgb(49, 137, 77);
    text-align: justify;
    transform: rotate(-15deg) skew(20deg) scaleX(6) scaleY(10);
}
.box1, .box2{
    background-color: rgb(34, 101, 169);
    color: white;
}
.box1{
    position: absolute;
    z-index: 1;
    width: 316px;
    top: 2em;
    left: 2em;
    font-size: 0.8rem;
    text-align: justify;
    padding: 10px;
}
.box1::first-line{
    width: 220px;
    border-bottom: 1px dashed white;
    padding: 5px;
    text-align: left;
    font-size: 1.1rem;
}
.box2{
    position: absolute;
    z-index: 1;
    padding: 10px 25px;
    top: 31rem;
    right: 22rem;
    text-align: center;
    font-size: 3.8rem;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <link href="https://fonts.googleapis.com/css2?family=Lora:wght@400;500&display=swap" rel="stylesheet"> 
    <title>Implementing a Layout using HTML & CSS</title>
</head>
<body>
    <nav>
    <ul>
        <li><a href="">home</a></li>
        <li><a href="">about us</a></li>
        <li><a href="">contact</a></li>
        <li><a href="">company</a></li>
        <li><a href="">services</a></li>
    </ul>
    </nav>
    <div class="name">
        <div class="title">TechCorporate</div>
        <div class="title2">Free PSD Website Template</div>
        <div class="contact">
            <p>Tel: xxxxxxx xxxxxxxx</p>
            <p>Mail: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0861666e67486c6765696166266b6765">[email protected]</a></p>
        </div>
    </div>
    <div class="blue">
        <div class="tech">TECHNOLOGY</div>
        <div class="box1">
            <p>Lorem ipsum dolor sit amet das</p>
            <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat, unde debitis quibusdam quas accusantium ipsa officia quo iste delectus modi voluptatibus harum rem saepe quod maxime quam. Velit, beatae quos ipsum dolor sit amet consectetur  elit. Placeat, unde debitis.</p>
        </div>
    </div>
    <div class="box2">Todays Technology »</div>
    
</body>
</html>

Answer №1

There is a substantial amount of work that needs to be done, and I have commenced the process of addressing it. The implementation of media queries is imperative for proper functionality.

body, html{
    margin: 0 auto;
    padding: 0;
    max-width: 960px;
    align-items: center;
    font-family: 'Lora', serif;
}
/* ****Start Nav******** */
nav ul{
    margin: 5px auto;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    justify-content: center;
}

li a{
    display: flex;
    text-decoration: none;
    text-transform: uppercase;
    padding: 20px 50px;
    align-items: center;
    text-align: center;
    margin: 2px;
    color: white;
    background-color: rgb(34, 101, 169);
}
/* ************* End Nav *************** */
/* ******Start 2nd Row with Title********** */
.name{
    max-width: 960px;
    margin: 20px auto;
    display: flex;
    padding: 0px 40px;
    align-items: center;

}
.title {
    Flex: 0 1 auto;
    font-size: 1.8rem;
    border-right: 1px solid black;
    padding-right: 10px;
    font-weight: 500;
}
.title2{
    padding-left: 10px;
    flex: 1 1 auto;
    font-size: 0.9rem;
    font-weight: 600;
}

.contact{
    margin-left: 0 auto;
    line-height: 3px;
    font-size: 0.7rem;
}
/* ******End 2nd Row with Title********** */
/* ********Start blue box with containers */
.blue {
    position: relative;
    z-index: 0;
    display: flex;
    max-width: 960px;
    margin: 0px 40px;
    height: 100vh;
    background-color: rgb(189, 217, 254);
    color: white;
    align-items: center;
    justify-content: center;
}
.tech{
    padding: 0px 10px;
    border-radius: 5px;
    background-color: rgb(49, 137, 77);
    text-align: justify;
    font-size: 9vw;
    transform: rotate(-15deg) skew(20deg);
}

.box1, .box2{
    background-color: rgb(34, 101, 169);
    color: white;
}
.box1{
    position: absolute;
    z-index: 1;
    max-width: 316px;
    margin-left: 2em;
    top: 2em;
    right: 2em;
    font-size: 0.8rem;
    text-align: justify;
    padding: 10px;
}
.box1::first-line{
    width: 220px;
    border-bottom: 1px dashed white;
    padding: 5px;
    text-align: left;
    font-size: 1.1rem;
}
.box2{
    position: absolute;
    z-index: 1;
    max-width: 20rem;
    padding: 10px 25px;
    left:20px;
    bottom: 20px;
    text-align: center;
    font-size: 1.8rem;
}

@media screen and (min-width: 1025px) {
.blue {
height: 53vh;
}
.tech{
font-size: 7rem;
}
.box2{
  font-size: 3.8rem;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <link href="https://fonts.googleapis.com/css2?family=Lora:wght@400;500&display=swap" rel="stylesheet"> 
    <title>Implementing a Layout using HTML & CSS</title>
</head>
<body>
    <nav>
    <ul>
        <li><a href="">home</a></li>
        <li><a href="">about us</a></li>
        <li><a href="">contact</a></li>
        <li><a href="">company</a></li>
        <li><a href="">services</a></li>
    </ul>
    </nav>
    <div class="name">
        <div class="title">TechCorporate</div>
        <div class="title2">Free PSD Website Template</div>
        <div class="contact">
            <p>Tel: xxxxxxx xxxxxxxx</p>
            <p>Mail: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8ce5e2eae3cce8e3e1ede5e2a2efe3e1">[email protected]</a></p>
        </div>
    </div>
    <div class="blue">
        <div class="tech">TECHNOLOGY</div>
        <div class="box1">
            <p>Lorem ipsum dolor sit amet das</p>
            <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat, unde debitis quibusdam quas accusantium ipsa officia quo iste delectus modi voluptatibus harum rem saepe quod maxime quam. Velit, beatae quos ipsum dolor sit amet consectetur  elit. Placeat, unde debitis.</p>
        </div>
         <div class="box2">Todays Technology »</div>
    </div>
</body>
</html>

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

Is there a way to obtain the Base64 data following the conversion of a div to an image?

I am not very experienced with JavaScript, but I wanted to convert a div to an image. I came across this helpful jsfiddle that showed me how to do it. $(function() { $("#btnSave").click(function() { html2canvas($("#widget"), { on ...

The CSS table-cell element causes adjacent table-cell content to reposition

The table inside the "center" div is causing the contents in the "left" div to be offset by a few pixels from the top (about 8 in my browser). When you add some text before the table, this offset disappears. Why is this happening? Is there a way to preven ...

What is causing FF and Chrome to not recognize these <form>'s?

My PHP logic is rendering the following forms with text inputs and a submit button. Everything works fine in IE, but in FF and Chrome, clicking the submit button reloads the page instead of going to the form action URL. I was surprised to find that the &l ...

Managing the height of a TextArea within a Flexbox environment

After exploring various methods for achieving auto-height in a textarea, I decided to go with the contenteditable approach as it seemed cleaner to me. However, while it worked perfectly on its own, it failed when placed within flexbox containers. I experi ...

hide the container while keeping the content visible

Currently, I am working on a map with zoom in and zoom out functionalities. My main concern is how to make the red section invisible while keeping the buttons visible. This will ensure that when users search for locations on the map, their view will not be ...

Top tips for utilizing CSS in a web component library to support various themes

Our team is currently in the process of developing a comprehensive design system that will be utilized across multiple projects for two distinct products. Each product operates with its own unique brand styleguide which utilizes design tokens, such as: Th ...

Display the scroll bar in HTML only when the content exceeds the maximum height

I am trying to display a scrollbar only if the content is larger than the specified max-height. However, it seems that the scrollbar is always enabled. <div style="text-align: left; font-size: 1.5rem; max-height: 7rem; overflow-y: auto;"& ...

Tips for adjusting mat button color with CSS when hovering over it

How can I use CSS to change the color of a Material button when hovering over it? mat-raised-button color="primary">button</button> ...

Select a hyperlink to access the corresponding tab

I've been playing around with bootstrap and AngularJS. I placed nav-tabs inside a modal-window and have it open when clicking on a link. However, I want the appropriate tab to open directly upon click. For example, if I click on "travel", I want the t ...

My CSS horizontal drop-down menu is causing the sub-navigation items to overlap each other

I'm having an issue where my sub navigation menu items are stacking on top of each other instead of displaying properly. Here is the code snippet causing the problem: /* STYLING FOR NAVIGATION MENU */ .nav-bar { width: 100%; height: 80px; ...

Creating a personalized webview in Appgyver Steroids: A step-by-step guide

I am planning to design the following layout: The main screen will display a web page There should be a sidebar on the left side The sidebar can be accessed by clicking on a 'hamburger' icon in the app header Currently, my app structure look ...

Angular application's NgbTooltip positioning

Within my Angular 2/4 project, I am utilizing ng-bootstrap along with its NgbTooltip component. Consider this HTML snippet: <div class="col-sm-8 text-ellipsis" ngbTooltip="'A very long text that does not fit'" placement="top" ...

table that can be scrolled horizontally

I am facing an issue similar to the one discussed in this thread about responsive design for html wide table. In essence, my problem involves a table that is wider than the container div, which has ten columns in width (using bootstrap). The challenge aris ...

Achieving the perfect background image size using Tailwindcss

Looking for a way to use an image with a height of 300px and a width of 1600px as a background in a div element? Although the div element's height can be extended beyond 300px, it results in an empty space at the top while covering the width. The de ...

Optimize the layout with Grid CSS to allow the last two items to dynamically occupy

I've been working on a layout that looks like this: X X X X X X X X A B Currently, I have used grid-template-columns: repeat(4, 1fr); to define the columns. However, what I actually want is for the last two items to take up the full width of the rem ...

Enhancing the appearance of unordered lists with CSS. Creating numbered lists

Here is a list that I am currently working with: <ul> <li>question1</li> <li>answer1</li> <li>question2</li> <li>answer2</li> </ul> I have applied the following CSS styling: ul { ...

Guide on showcasing SQL information in HTML using AJAX and JQuery for a dynamic table display

I have some data stored in a SQL file and I'm looking to present it as a table in HTML using AJAX JQuery. Although the data is correctly retrieved when inspected, I am struggling with displaying it on my HTML page. This concept is new to me and I&apos ...

Is it possible for a typo3 website to automatically redirect users to a mobile-friendly version?

I have put together a landing page for my website with numerous content elements using only HTML and then pasted it into my typo3 backend. I ended up with separate HTML codes for desktop view and mobile view because I couldn't figure out how to make t ...

Search for every div element and locate the ul element within it. Calculate the total number of table rows present in the ul element. Add this

There is a list on my website with a sublist called .cart-items. This sublist contains a table with multiple rows. My goal is to iterate through each .cart-select item and count the number of tr elements within the cart-items. The count should then be disp ...

What is the process for extracting Html sub elements from parent elements?

While using my HTML editor, specifically the Kendo Editor, to generate bullets and indent them for sub-bullets, I noticed that the HTML output wasn't as expected. <ul> <li>Focusing on lifetime income replacement <ul>< ...