What is the best way to utilize images as borders for a div tag to create a unique and customized border appearance using images?

Hello, I am struggling to find a solution to a CSS problem. I have applied CSS styles to create border images for a div container, but the right image is not positioned correctly - it leaves space on the right side of the container when stretched out. Any ideas on how to fix this issue?

div#container{
    position:relative;
    margin-left:120px;
    margin-right:120px;
    float:top;
    /*margin-top:-14px;*/
    margin-bottom:50px;
    /*border:2px solid #000;*/
    width:auto;
    height:100%;

    }   
ul#ulmenu{
    padding-left:0;
    list-style:none;

    }
div#menus{
    width:900px;
    margin-top:7px;
    margin-bottom:5px;
    /*display:block;*/

    }       
ul#ulmenu li{
    margin-top:15px;
    float:left;
    line-height:16px;
    }

ul#ulmenu a{
    margin-top:13px;
    text-decoration:none;
    font-family:Verdana, Geneva, sans-serif;
    font-size:16px;
    font-weight:bold;
    padding:8px;
    border:2px solid #060;
    background:#069;
    color:#FFF;
    }
ul#ulmenu a:hover, ul#ulmenu a:visited{
    background:#09F;
    color:#C06;
}
div#left-image{
    position:absolute;
    left:0;
    width:28px;
    height:100%;
    float:left;
    background:url(nios%20admin%20images/images/images/border-left.png) repeat-y;   
    }

div#right-image{
    position:absolute;
    display:compact;
    right:0;
    margin:0;
    width:30px;
    height:100%;
    float:right;
    background:url(nios%20admin%20images/images/images/border-right.png) repeat-y;
    }   
div#bottom{
    position:absolute;
    bottom:0;
    width:100%;
    /*border:2px solid #000;*/
    height:36px;
    z-index:100;
    }   
div#bottom-left{
    width:51px;
    height:36px;
    background:url(nios%20admin%20images/images/images/corner-left.png) no-repeat;
    float:left;
    }   
    div#bottom-center{

    height:36px;
    background:url(nios%20admin%20images/images/images/bottom-image.png) repeat-x;
    margin-right:49px;
    /*clear:both:*/
    }       
div#bottom-right{
    width:49px;
    height:36px;
    background:url(nios%20admin%20images/images/images/corner-right.png) no-repeat;
    float:right;
    margin-top:-36px;

    }   

div#main-containts{
    position:absolute;
    margin-right:30px;
    left:25px;
    right:30px;
    padding:25px 10px;
    text-align:center;
    width:auto;}    
div#data-containts{
    /*position:absolute;*/
    margin-top:50px;
    padding-top:50px;
    }                   
#container #main-containts #data-containts strong {
    font-family: Tahoma, Geneva, sans-serif;
    color: #C03;
    font-size: 18px;
}
.msg {
    font-family: Tahoma, Geneva, sans-serif;
    font-weight: bold;
    color: #C06;
    font-size: 18px;
}
div#workspace{
    position:relative;}
</style>

</head>
<body>
<div id="workspace">
<div id="adminwrapper">
<div align="center">
<img src="images/adminbg-2.png" />
</div>
</div>

<div id="container">
<div id="left-image"></div>

<div id="main-containts" align="center">
    <div id="menus">
    <ul id="ulmenu">
    <li><a href="index.php?act=admin_logout" >Logout</a></li>
    <li><a href="javascript:void(0);" OnClick="c_pass()">Change-Password</a></li>
    <li><a href="#" >Back-Up</a></li>
    <li><a href="students.php?act=show_stud_rec" >Students</a></li>
    </ul>
    </div>
    <div id="data-containts">
    <span class="msg">{$msg}</span> </div>
    <br/>
    <p>
   {$body_data}
    </p>
</div>


<div id="right-image"></div>

   <div id="bottom">

       <div id="bottom-left"></div>
       <div id="bottom-center"></div>
       <div id="bottom-right"></div>

   </div>


</div>
</div>
</body>
</html>

Answer №1

If you're looking to add a unique touch to your borders, consider using the border-image CSS property.

For a detailed explanation, check out this resource: http://css-tricks.com/understanding-border-image/

You can also see a demo of the effect here:

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

What is the process for changing the background color when a button or div is pressed, and reverting the color back when another button or div is

Looking to customize a list of buttons or divs in your project? Check out this sample layout: <button type="button" class="btn" id="btn1">Details1</button> <button type="button" class="btn" id="btn2">Details2</button> <button ty ...

What steps can I take to troubleshoot the 'Uncaught DOMException: failed to execute add on DOMTokenList' error?

I am looking to create media icons <div class="contact"> <span> <i class="fa fa-phone"></i> </span> <span> <i class="fa fa-facebook"></i> </spa ...

Creating a transparent background in a three.js canvas: a step-by-step guide

I came across a wave particle animation on Codepen (https://codepen.io/kevinsturf/pen/ExLdPZ) that I want to use, but it has a white background. However, when I try to set the body background to red, it doesn't show up once the canvas is rendered. I ...

PHP 5's HTML Form Library

Currently in search of an alternative to QuickForm. I have encountered performance problems with QF, specifically when dealing with a large number of options in combobox. I prefer something that is more object-oriented like Zend_Form, but without the exc ...

The scroll bar is visible on the scroll box, but unfortunately it is not functional in Internet Explorer 8

http://example.com/code <div style="width:625px;height:220px;overflow-y:hidden;overflow-x:scroll;z-index:10;"> <table width="1000" height="114" border="1"> <tr> <td width ...

Retrieve the value of a JavaScript variable within an HTML or EJS document

My JavaScript file, named main.js, contains a JSON object like the following: const person = {}; person.AGE = '17'; person.GENDER = 'Male'; To load this file in my .ejs file, I use the following code: <script type="text/javascript ...

Learning how to use Express.js to post and showcase comments in an HTML page with the help of Sqlite and Mustache templates

I am facing a persistent issue while trying to post new comments to the HTML in my forum app. Despite receiving various suggestions, I have been struggling to find a solution for quite some time now. Within the comments table, each comment includes attrib ...

Creating a dynamic sidebar navigation that adapts seamlessly across all devices, including desktop and mobile platforms

I am currently using Bootstrap 5 to design a resume webpage. While I have achieved the desired look, I am facing an issue with making the sidebar fixed without overlapping other content when the page is resized to be smaller. Initially, I attempted to use ...

The image slideshow on W3 Schools displays images in a stacked formation

Utilizing this code snippet from W3 Schools to incorporate an image slideshow into my web project. However, upon page load/reload, the images appear stacked vertically rather than horizontally (one above and one below). The slideshow functions properly aft ...

Tips for adding and removing active class with navbar links using JavaScriptonclick

I need help with toggling the "li-active" class on my navigation bar links. Currently, when I click on a link, the "li-active" class is transferred from the previous link to the newly clicked link instead of removing it first. Can someone please assist me ...

Can information be transferred to a CSS document?

Currently working on developing a content management system (CMS) using PHP and exploring the possibility of passing a URL to an image. In my PHP pages, I am utilizing Twig templates and the {{ image1url }} to display the image URL. Is there a way to pas ...

AngularJS: Understanding the difference between ng-show and using display:none

I recently encountered a scenario where I needed to hide an HTML element by default using CSS. Here's how I did it: HTML: <div class="box"> </div> CSS: .box { display: none; } However, I wanted to be able to show and hide the elem ...

What is the best way to utilize variable fonts with Google Fonts?

Traditional fonts typically require a separate file for each weight variant, such as 300, 400, and 500. However, with variable fonts, all weight combinations can be accessed through a single compact font file. This is extremely advantageous for web design. ...

There was a type error that occurred because the property 'addEventListener' could not be read from an undefined value

Encountering an issue with the JavaScript libraries three.js and OrbitControls.js despite following a tutorial: However, an error is being displayed in the console: Uncaught TypeError: Cannot read property 'addEventListener' of undefined at ne ...

Chrome on IOS: Experiencing screen freezing while scrolling

1) I'm working with Material UI in React JS. I have added a simple scrollable code, but when I reach the bottom of the screen/scroll, it freezes. 2) I also tried it with a simple HTML page and it worked correctly. <div style={{ ...

Set the dropdown item as selected using AngularJS

I have created a demo of an AngularJS dropdown menu, and it's working perfectly. Now, I want to make the selected item appear active. I'm not sure how to achieve this. Can anyone please assist me? I am using the Angular-Dropdown.js library. Here ...

What advantages does Snap.svg offer compared to the HTML5 native SVG DOM API?

Can the differences between Snap.svg and HTML5 native SVG DOM API be compared to jQuery vs HTML5 native DOM? Apart from potential cross-browser disparities, assuming modern browsers support SVG well, what advantages does Snap.svg offer? What are the pros ...

Create an HTML button on the homepage that directs users to the "about" page

I've been struggling to make a button in my Ionic app navigate to a different page upon clicking. Despite being new to Ionic, I've spent hours trying to solve this issue. Below is the HTML code in home.page.html: <ion-header> &l ...

Using jqGrid to load additional JSON data after the initial local data has already been populated in the

I encountered a specific issue: I have a compact form with four choices. Users can choose to fill them out or not, and upon clicking 'Ok', a jqGrid is loaded with data based on those selections. To accommodate dynamic column formatting, my servle ...

To showcase the entire contents of a specific column from one table onto a different table on the following page once the box is ticked

Everything seems to be running smoothly, except for one issue. When a row contains the value "hello world" in a column on the first page, it only displays "hello" in the item column on the second page. I'd like it to show the full value "hello world" ...