Approach to CSS Layout: Creating Rounded Corners without CSS3 using images on all sides

  • I am faced with the challenge of creating a CSS layout that must adhere to specific minimum width and height requirements, yet expand to occupy 80% of the browser size.
  • The main div I need to design should have rounded corners, utilizing images due to lack of CSS3 support. In addition to the corners, there are images running between them on the top, bottom, left, and right sides to create a drop shadow effect.
  • My current approach involves using position:relative for the main div and position:absolute for the corners, which works well so far. However, I am encountering an issue when trying to make the middle images expand to fill the space between the corners; they end up extending past the boundaries of the div.
  • While I have provided images and code below, I am open to alternative solutions. You can choose to use background colors in your solution instead of relying on the images I have provided.

This is my desired outcome:

The image set for the container can be found here:

https://i.sstatic.net/gCgFR.jpg

Here is a snippet of the code ...

HTML:

<html>
<head>
    <link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
    <div class="pageWrapper">
        <div class="contentWrapper">
            <span class="top-left"></span>
            <span class="top-middle"></span>
            <span class="top-right"></span>
            <span class="bottom-left"></span>
            <span class="bottom-middle"></span>
            <span class="bottom-right"></span>
            <div class="content">
                <p>
                    Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
                    Ut viverra lectus vitae est ullamcorper a tempus est commodo. 
                    Phasellus et pulvinar risus. Cras quis aliquet odio. Ut condimentum porta mi ultrices elementum. 
                    Maecenas feugiat magna at tellus convallis congue. Aenean tincidunt rutrum varius. Aenean nec eros id odio dapibus faucibus. 
                    Pellentesque blandit gravida erat id sodales. Etiam nunc odio, pharetra nec aliquam a, gravida at metus. Nullam dapibus vulputate blandit. 
                    Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum ullamcorper lectus ut sapien scelerisque 
                    vitae ullamcorper mauris venenatis.
                </p>
            </div>  
        </div>
    </div>
</body>

CSS:

body {
background-color: #eeeee7;
}

.pageWrapper {
margin: 0px auto;       /* centers the div horizontally */
min-width: 900px;
min-height: 430px;
height: 80%;
width: 80%;
background-color: red;
}

.contentWrapper {
position: relative;        /* makes our corners absolute relative to our container not our browser window    */
background-color: yellow;
height: 100%;
width: 100%;
padding-right: 34px;
padding-left: 34px;
padding-top: 155px;
}

.top-left,
.top-right {
position: absolute;
height: 155px;
width: 34px;
background-color: blue;
}

.bottom-left,
.bottom-right {
position: absolute;
height: 29px;
width: 34px;
}

.top-left {
top: 0;
left: 0;
background-image:url('images/cornerLeftTop.jpg');
 }
 .top-right {
top: 0;
right: 0;
background-image:url('images/cornerRightTop.jpg');
 }
.bottom-left {
bottom: 0; 
left: 0;
background-image:url('images/cornerBottomLeft.jpg');
 }
.bottom-right {
bottom: 0;
right: 0;
background-image:url('images/cornerBottomRight.jpg');
 }
 .top-middle {
position: absolute;
top: 0;
left: 34px;
height: 155px;
width: 100%;
background-image:url('images/headerMiddle.jpg');
}

.bottom-middle {
position: absolute;
bottom: 0;
height: 29px;
width: 100%;
background-image:url('images/footerMiddle.jpg');
}

.middle-left {

}

.middle-right {

}

Answer №1

This solution has been successful for me, although I am still refining the min-width aspect which is not compatible with Internet Explorer 8 and earlier versions. While I understand that there are more modern methods to achieve this, my workplace requires continued support for users on Internet Explorer 6. Despite its limitations, this approach works effectively!

<html>
<head>
    <link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
    <div class="pageWrapper">
        <div class="contentWrapper">    
            <div class="headerMiddle">
            </div>
            <span class="top-left"></span>
            <span class="top-right"></span>
            <div class="contentRight">
            </div>                                  
            <div class="contentLeft">
            </div>  
            <div class="content">                   
                <p>
                    Lorem ipsum dotor sit amet, consectetur adipiscing elit. 
                    Ut viverra lectus vitae est ullamcorper a tempus est commodo. 
                    Phasellus et pulvinar risus. Cras quis aliquet odio. Ut condimentum porta mi ultrices elementum. 
                    Maecenas feugiat magna at tellus convallis congue. Aenean tincidunt rutrum varius. Aenean nec eros id odio dapibus faucibus. 
                    Pellentesque blandit gravida erat id sodales. Etiam nunc odio, pharetra nec aliquam a, gravida at metus. Nullam dapibus vulputate blandit. 
                    Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum ullamcorper lectus ut sapien scelerisque 
                    vitae ullamcorper mauris venenatis.
                </p>
                <p>
                    Lorem ipsum dotor sit amet, consectetur adipiscing elit. 
                    Ut viverra lectus vitae est ullamcorper a tempus est commodo. 
                    Phasellus et pulvinar risus. Cras quis aliquet odio. Ut condimentum porta mi ultrices elementum. 
                    Maecenas feugiat magna at tellus convallis congue. Aenean tincidunt rutrum varius. Aenean nec eros id odio dapibus faucibus. 
                    Pellentesque blandit gravida erat id sodales. Etiam nunc odio, pharetra nec aliquam a, gravida at metus. Nullam dapibus vulputate blandit. 
                    Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum ullamcorper lectus ut sapien scelerisque 
                    vitae ullamcorper mauris venenatis.
                </p>                    
            </div>

            <div class="footerMiddle">
            </div>
            <span class="bottom-left"></span>
            <span class="bottom-right"></span>      
        </div>  
    </div>
</body>

body {
    background-color: #eeeee7;
    text-align:center;
}

.pageWrapper {
    margin: 0px auto;
    min-width: 900px;
    height: 768px;
    width: 80%;
}

.contentWrapper {
    position: relative;
    background-color: white;
    height: 100%;
    width: 100%;
    padding-top: 155px;
    text-align: left;
}

.content {
    padding: 75px;
}

.headerMiddle {
    position: absolute;
    top: 0;
    left: 0;
    height: 155px;
    width: 100%;
    background-image:url('images/headerMiddle.jpg');
}

.footerMiddle {
    position: absolute;
    bottom: 0;
    right: 0;
    height: 29px;
    width: 100%;
    background-image:url('images/footerMiddle.jpg');    
}

.contentLeft {
    float: left;
    height: 100%;
    width: 34px;
    background-image:url('images/contentLeft.jpg');
}

.contentRight {
    float: right;
    height: 100%;
    width: 34px;
    background-image:url('images/contentRight.jpg');
}

.top-left,
.top-right {
    position: absolute;
    height: 155px;
    width: 34px;
    background-color: blue;
}

.top-left {
    top: 0;
    left: 0;
    background-image:url('images/cornerLeftTop.jpg');
}

.top-right {
    top: 0;
    right: 0;
    background-image:url('images/cornerRightTop.jpg');
}

.bottom-left,
.bottom-right {
    position: absolute;
    height: 29px;
    width: 34px;
}

.bottom-left {
    bottom: 0; 
    left: 0;
    background-image:url('images/cornerBottomLeft.jpg');
}
.bottom-right {
    bottom: 0;
    right: 0;
    background-image:url('images/cornerBottomRight.jpg');
}

.minWidth {
    width: 600px;
    height:1px;
}

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 it possible to toggle all parent targets in Bootstrap?

When trying to showcase my point, I believe it is best demonstrated by visiting Bootstrap documentation at https://getbootstrap.com/docs/4.0/components/collapse/ and viewing the "multiple targets section." In this section, you will find three buttons: togg ...

Utilize NodeJS to redirect external asset requests to the local filesystem

Consider this scenario: We are tasked with fetching an image from an S3 bucket. <img src="https://s3-us-west-2.amazonaws.com/{BUCKET}/logo.png" /> Due to limited internet connectivity, I must find a way within my Express server to redirect requests ...

Having trouble with jQuery field validation not functioning as expected?

I'm trying to implement user input validation when the submit button is clicked, but I can't seem to get it to work. Using jQuery $(document).ready(function() { function validateForm() { if ($('#u').value() == '') ...

What steps can be taken to add a radio button group to a form in order to choose between the smoking and non-smoking sections of a restaurant?

I'm trying to replicate the functionality of radio buttons within a bootstrap form-group, where a line in a form contains multiple buttons ("btn btn-success" for example) that can be selected, but only one at a time. I am aiming for an output like thi ...

Having Trouble With Your Font Display?

I am confident that my code is correct. Here's a snippet from what I've done: <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="homepage.css"/> </head> <body> <div id="menu"> &l ...

Having difficulty extracting information from an HTML page using Swift

I'm attempting to convert data retrieved from an HTML page into a readable format, but the string urlContent is showing as nil even though the data received from the NSURLSession is not null. This is my approach: var city = "London" var url = NSURL ...

Sort the currency column in an HTML table through JavaScript

I have a code snippet below that I'm currently utilizing to arrange columns in an HTML table. The code works perfectly for alphabetical sorting and also for single-digit numbers. However, when attempting to sort a column containing currency values, t ...

What is the best way to adjust the size of a column when hovering

What I am attempting to achieve is, I would like the column box to have a 100% width, and when it is hovered over, I want it to transition to the left, with the width of the column box being about 60%, revealing a second block that shows up as 20% width o ...

Guide on hiding a div element when clicked outside of it?

How can I create a dropdown feature in Khan Academy where it disappears when clicked outside but stays visible when clicked inside, using JavaScript/CSS/HTML? The current implementation closes the dropdown even on internal clicks. The code includes an even ...

Pattern matching: Identify text elements specifically within an HTML tag

I've been experimenting with a text highlighting script. Check out my initial attempt here. Here's the code snippet: http://jsfiddle.net/TPg9p/3/ However, I encountered a problem – it only works with simple strings and not those containing HT ...

Seamless scrolling experience achieved after implementing a header that appears when scrolling up

My goal is to create a header with the following functionalities: Initially displays with a transparent background Upon scrolling down the page by 25px, it will dynamically add the header--maroon class to the header, which alters the background color and ...

Determine whether the server request originated from an Ionic mobile application

Currently, we are in the final stages of completing an Ionic project with a PHP backend. To enhance the security of our backend and protect it from external influences, we aim to restrict access to the backend only from within the Ionic project (native app ...

Exploring the possibilities of integrating Storybook/vue with SCSS

After creating a project with vue create and installing Storybook, everything was running smoothly. However, as soon as I added SCSS to one of the components, I encountered the following error: Module parse failed: Unexpected token (14:0) File was process ...

What is the best way to create a blurred effect on an image during loading, and then transition to a sharp image once it is fully loaded?

I'm currently working on a project where I want the images to display as a blurred preview initially, and then become clear once fully loaded. This is similar to the feature seen on Instagram, where the app shows a blurred image before displaying the ...

Combining Files in Angular 2 for Optimal Production Deployment

What is the best method for packaging and combining an Angular 2 application for production? My goal is to have an index.html file and a single app.min.js file. Although the Angular 2 documentation mentions using webpack, I found it to be overly complex f ...

ControlOrbiter - limit panning motion

Is there a way to restrict the camera's panning movement within a scene? I've experimented with adjusting the pan method in orbitControls, but I'm not completely satisfied with the outcome. I am hoping for a more convenient and proper solut ...

What is the maximum file size that the data link is able to store?

For instance, a file like an image, video, or sound can be saved in the data link Take an image for example, it may be stored with the initial link: data:image/jpeg;base64,/..... followed by various characters. But, is there a specified size limit at whic ...

Hover over a child DIV element to dynamically alter the style of its parent DIV element

Attempting to create a simple CSS hover effect. <div class="menu"> <div class="child"></div> </div> <div class="nav"> <div class="item1"></div> </div> The desired outcome is for the style of < ...

Display various JavaScript function outputs in an HTML table for convenient tracking

Thanks to a helpful user on this platform, I was able to capture data from a JavaScript function and display it in an html table. However, I now have another query. How can I execute the function multiple times during page load and record the results in ...

Can we dynamically adjust font size based on the width of a div using CSS?

My div is set to 70% width and I have a specific goal in mind: To fill that div with text To adjust the font size so that it takes up the entire width of the div https://i.stack.imgur.com/goVuj.png Would it be possible to achieve this using only CSS? B ...