Is it possible to use an SVG image as a border with a variable height in CSS

Check out this jsfiddle for my current project's nav setup. I want to center the logo in the middle of the nav with three links centered around it. However, I need the design to be responsive across various screen widths. Any advice on how to achieve that?

I also need to use a .png as a border on divs without specifying a fixed height. But when I set it to height:auto, the background-color disappears. How can I solve this issue?

Here's the HTML code:

<div id="header-wrap" class="group">
<nav>   
    <a href="index.html"><img class="logo" src="http://i60.tinypic.com/1zxqqm1.png" alt="Cat Town Cafe & Adoption" /></a>

    <ul>
        <li><a href="index.html">ABOUT</a>
        </li>
        <li><a href="index.html">OUR CATS</a>
        </li>
        <li><a href="index.html">RESERVATIONS</a>
        </li>
        <li><a href="index.html">DONATE</a>
        </li>
        <li><a href="index.html">HELP OUT</a>
        </li>
        <li><a href="index.html">CONTACT</a>
        </li>
    </ul>
</nav>
</div>

The CSS code:

#header-wrap {
width: 100%;
height: auto;
position: relative;
background-color: #E6D7B8;
z-index: 5;
}
#header-wrap:after {
width: 100%;
height: 4px;
background: url("http://i57.tinypic.com/30uxn47.png") repeat-x;
-webkit-transform: rotate(-180deg);
-moz-transform: rotate(-180deg);
-ms-transform: rotate(-180deg);
-o-transform: rotate(-180deg);
transform: rotate(-180deg);
position: absolute;
bottom: -4px;
left: 0;
display: block;
content:"";
z-index: 5;
}
nav {
background: #E6D7B8;
height: 60px;
position: relative;
}
nav ul {
margin: 0 auto;
padding: 0;
list-style: none;
}
nav li a {
display: block;
float: left;
padding: 0 18px;
height: 60px;
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
position: relative;
font: 400 14px'Bitter';
letter-spacing: 0.05em;
color: #893B4E;
text-transform: uppercase;
text-decoration: none;
}
nav li a:hover {
box-shadow: inset 0px 4px 0px #4C264B;
}
nav li a:hover:before {
width: 100%;
height: 100px;
background: linear-gradient(#4C264B, transparent);
display: block;
content:"";
position: absolute;
left: 0;
z-index: -1;
}
nav ul li {
float: left;
}
nav ul li:nth-of-type(4) {
margin-left: 277px;
}
.logo {
position: absolute;
left: 50%;
margin: 0 0 0 -135px;
max-width: 270px;
z-index: 100;
}

Answer №1

Place your logo with the class ".logo" inside an unordered list "ul". Don't forget to adjust your CSS accordingly.

Access Fiddle

HTML Structure:

<div id="header-wrap" class="group">
  <nav>
    <ul>
      <li><a href="index.html">ABOUT</a>

      </li>
      <li><a href="index.html">OUR CATS</a>

      </li>
      <li><a href="index.html">RESERVATIONS</a>

      </li>
      <li class="logo">
        <a href="index.html"></a>
      </li>
      <li><a href="index.html">DONATE</a>

      </li>
      <li><a href="index.html">HELP OUT</a>

      </li>
      <li><a href="index.html">CONTACT</a>

      </li>
    </ul>
  </nav>
</div>

CSS Style:

#header-wrap {
    width: 100%;
    height: auto;
    position: relative;
    background-color: #E6D7B8;
    z-index: 5;
}
#header-wrap:after {
    width: 100%;
    height: 4px;
    background: url("http://i57.tinypic.com/30uxn47.png") repeat-x;
    -webkit-transform: rotate(-180deg);
    -moz-transform: rotate(-180deg);
    -ms-transform: rotate(-180deg);
    -o-transform: rotate(-180deg);
    transform: rotate(-180deg);
    position: absolute;
    bottom: -4px;
    left: 0;
    display: block;
    content:"";
    z-index: 5;
}
nav {
    background: #E6D7B8;
    height: 60px;
    position: relative;
    width: 100%;
    margin: 0 auto;
}
nav ul {
    margin: 0 auto;
    width: 870px;
    padding: 0;
    list-style: none;
}
nav li a {
    display: block;
    float: left;
    padding: 0 18px;
    height: 60px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    font: 400 14px'Bitter';
    letter-spacing: 0.05em;
    color: #893B4E;
    text-transform: uppercase;
    text-decoration: none;
}
nav li:not(.logo) a:hover {
    box-shadow: inset 0px 4px 0px #4C264B;
}
nav li:not(.logo) a:hover:before{
    width: 100%;
    height: 100px;
    background: linear-gradient(#4C264B, transparent);
    display: block;
    content:"";
    position: absolute;
    left: 0;
    z-index: -1;
}
nav ul li {
    float: left;
}
.logo a {
    width: 200px;
    height: 130px;
    position: relative;
    background: url(http://i60.tinypic.com/1zxqqm1.png) no-repeat;
    background-size: 100% 100%;
    background-position: 0% 0%;
    z-index: 10;
}

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

External CSS stylesheets

I have encountered the following HTML code: <div class="entry"> <p></p> //text-indent here <blockquote> <p></p> //no text-indent here </blockquote> </div> I am trying to apply a ...

Arranging buttons that are generated dynamically in a vertical alignment

Currently, I am in the process of creating a webpage for various items, and everything is going well so far. However, I have encountered an issue while attempting to vertically align the buttons that I am generating using JavaScript within the document. I ...

Implementing Node.js with browser cache and handling 304 responses

I am currently in the process of creating a single page application with a standard HTML layout as shown below: <html> <head> <title>...</title> <link rel="stylesheet" media="all" type="text/css" href="css/main.css"> ...

Set the position to fixed so it doesn't scroll

Is there a way to create a fixed position div that remains in place when the user scrolls, similar to the effect shown in this example image? Position Absolute: https://i.sstatic.net/4RAcc.png Position Fixed (desired effect): https://i.sstatic.net/3DIna. ...

Tips for saving the visibility status of a <div> in your browser bookmarks?

Currently, I am in the process of developing a single webpage (index.html). The navigation bar at the top includes links to hash references (DIV IDs). If JavaScript is enabled, clicking on these links triggers a JavaScript function with the onclick attribu ...

Tips for keeping the scroll position of a bootstrap table when reloading the page

Displayed below is a bootstrap table with specific features. <div class="row"> <table id="question-selection" class="table table-sm table-hover table-wrapper"> <tbody> {% for placer in chapter_questions %} ...

Instructions for creating scrollable MaterializeCSS tabs when there are too many tabs to fit within the width of the container without scrolling

Here is an example code (SSCCE) that showcases the issue I am facing. The MaterializeCSS frontend framework documentation states: Scrollable Tabs Tabs automatically become scrollable Source However, when I attempt to use more tabs than can fit on the ...

The function element.innerHTML is invalid when trying to assign an object value as an option

Hey there! I'm currently working on a JavaScript project where I have an input that retrieves text from an array. Each option in the array needs to be linked to an object so I can utilize its attributes. const data = [ { name: "SIMPLES NACION ...

Extracting a parameter from a URL using C#

Imagine having a URL such as http://google.com/index.php?first=asd&second=mnb&third=lkj What is the method to extract the second value (mnb) using C#? ...

I've noticed that my alert is not appearing when I click submit. Can someone please help me figure out what I could

I am having trouble getting my alert to display when the form is not validating. It should show an alert message if the form is valid but it's not working as expected. I've spent hours trying to fix this issue with no luck. I appreciate any help ...

Unable to implement CSS styles on the provided HTML code

I'm currently working on integrating evoPDF into my asp.net application. When I click on a part of the HTML file, I send that portion using AJAX. So far, everything is working well up to this point. However, when I try to use the following methods fro ...

I want to create a Bootstrap 4 card deck that includes expand/collapse functionality for its content. The expanded content should only impact the current

I am experiencing an issue with my card decks and expand/collapse functionality. Currently, when I expand one card in the deck, all the other cards in the row also expand, leaving a large blank area. This becomes problematic especially when the content is ...

Move the accordion slider to the top of the browser

I'm working with an accordion menu that has some long content. To make it more user-friendly, I want to add a slide effect when the accordion items are opened. Right now, if you open the first two menu items, the last item's content is cut off a ...

Tips on adjusting the size of an HTML canvas specifically for the display

Currently, I am working on an innovative project utilizing HTML5 and canvas: The challenge at hand is to draw on a canvas with dimensions of 2200px/1600px (width/height), display it on my website in a smaller window sized at 600px/400px. However, post cli ...

What is the best way to incorporate web components into a React Js project?

I am currently unfamiliar with web components. My main goal is to integrate Google Material Components into my React.js project. Google Material Web Component can be found here: https://github.com/material-components/material-components-web Is there a ...

Transforming the MUI CircularProgress into a half circle shape

After utilizing CirculaProgress, I was able to achieve the following: Is there a simple method to transform it into a semicircle like shown here? ...

Another option instead of preloading images

Currently, I am in the process of creating a jQuery slideshow. After reviewing numerous tutorials on the subject, it appears that most recommend preloading images using code similar to the following: imageArray[imageNum++] = new imageItem(imageDir + "02. ...

Centralized Title / Side-aligned Menu

Good day, I am in need of assistance with a menu layout for my website. My goal is to have the title centered with the menu flexed out to the sides, but I'm encountering some issues. The colors included are just for testing purposes and will be update ...

I have configured my CSS styles in the module.css file of my Next.js application, but unfortunately, they are not being applied

I recently developed a nextjs with electron template application: Here is the link to my code on CodeSandbox: https://codesandbox.io/s/sx6qfm In my code, I have defined CSS classes in VscodeLayout.module.css: .container { width: '100%'; he ...

What is the best way to include a dropdown menu in a navigation bar?

I am looking for guidance on adding a dropdown menu to my navbar in place of the "social media" section. Below is the code snippet I have been working with: <span class="navbar-toggler-icon"></span> </button> <div class="co ...