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

Is it possible to create a mouse-following effect with lighting using Javascript

Recently, I've been honing my Javascript skills and decided to create a follow-mouse function. After successfully implementing it, I started brainstorming a new concept that I'm unsure is achievable. Is there a way to develop an "orb of vision" ...

My navigation bar is giving me a bit of trouble, as there are two separate issues that seem to be interconnected

Looking for some help with my navigation bar layout. You can also check out the code on fiddle http://jsfiddle.net/SgtRx/ (should have done this earlier, sorry). I'm a beginner when it comes to coding, so please bear with me if I make any mistakes. ...

The height of a DIV element can vary based on

Looking at this div structure: DIV3 has a fixed height. The nested DIV5 will be receiving content from Ajax, causing its height to change. Additionally, there are some DHTML elements inside it that also affect the height. DIV5 has a fixed min-height set. ...

Performance Issues Arise with Rapid Clicking [jQuery]

Having trouble with a gallery script I created that includes thumbnails, a large image, and navigation arrows. When you rapidly click on thumbnails or arrows during the transition, it causes delays in the process. The more clicks you make, the more noticea ...

Show loading message on keypress using jQuery

I need assistance with a unique jQuery script for the desired functionality: While inputting text into the text field, I would like the adjacent 'Load' text to be displayed. If typing stops, the 'Load' text should change to 'Del& ...

Code error detected on basic webpage

I've been experimenting with my local storage and have encountered a strange issue. The code example that I had previously tested successfully is now not working, and I can't figure out what went wrong. Check out this link for additional informa ...

What could be preventing my XPath from selecting a link/button using its label text?

<a href="javascript:void(0)" title="home"> <span class="menu_icon">Possibly more content could go here</span> Home </a> When I use //a as the XPath in the above code, it is highlighted. However, when I try //a[contains(text ...

I am attempting to retrieve the value of a 'td' element using jQuery, but it consistently returns 'null'

My task involves extracting the value of a specific cell within a table to filter out unwanted rows. However, every time I attempt to retrieve the value of that cell, it consistently returns null or nothing at all. Despite referencing various sources and s ...

Make sure all the table rows have the same height to completely fill the table regardless of the number of rows

Looking for a solution to create a table with a fixed height of 280px, whether it has 3 or 4 rows. Is there a method to adjust the row heights based on the number of rows in the table, so that they fill up the table's height? To clarify, when the ta ...

Initiate Bootstrap 4 dropdown menus from the initial menu point

I need the dropdown menus to align with the position of the first dropdown. There are multiple dropdowns on the page. Check out the screenshot for reference. JSFiddel: https://jsfiddle.net/kfh9Lbep/ Any ideas on how to achieve this alignment? <div cl ...

Adjust picture to fit in div and align vertically

JSFiddle In my fluid layout, I have a div with a required aspect ratio of 1:1. This div can contain text, an image, or both. The challenge is to vertically align the text and ensure the image fits within the div without exceeding its boundaries or losing ...

Implement a fullscreen hero image on a specific blogroll template page in Wordpress

My portfolio website uses custom page templates for each page. The blog page is not the landing page, but an interior page. I have been able to add a custom hero image to every page template except for the blog page. Currently, I am using the content.php p ...

Guidelines for implementing a logout feature in Django using templates

Here is my views.py file: from django.shortcuts import render from django.views.decorators.csrf import csrf_exempt import os # Create your views here. @csrf_exempt def index(request): if('loggedIn' in request.session): id = request. ...

What is the best way to design a scalable row of square elements using Bootstrap 5?

Looking to create a set of 6 Bootstrap 5 cards in square dimensions to function as buttons. Each card should be col-xl-2 wide and exactly square in height. I've started creating the cards with the code below. Can anyone provide guidance on how to ach ...

Customizing the main icon in the Windows 10 Action Center through a notification from Microsoft Edge

I am facing an issue with setting the top icon of a notification sent from a website in Microsoft Edge. Let's consider this code as an example: Notification.requestPermission(function (permission) { if (permission == "granted") { new ...

Looking to adjust the width of a Bootstrap dropdown menu?

I am trying to adjust the width of my dropdown menu Here is a link to jsfiddle with my code: [jsfiddler][1]. On the right side of the main menu, I have a languages dropdown menu. When it expands, its width is very large and I want it to match the main m ...

Refreshing HTML content using event delegation in JavaScript

Currently, I am attempting to dynamically load additional HTML content onto my webpage when a button is clicked. Here is the code that I have implemented so far: Main HTML Code: <div class="row" id="gallery-wrapper" > <di ...

Is there a way to prevent the contents of my div from overflowing beyond my other div?

Hey there! I'm fairly new to this whole web design thing, only a few months in. Currently, I'm in the process of creating a website for my school. However, I've hit a bit of a snag with different div containers holding various parts of my ...

Struggling to create a BMI Calculator using JS, the result is consistently displaying as 'NaN'

Having trouble creating a BMI Calculator using JavaScript. The issue I'm facing is that the calculation always returns 'NaN'. I've tried using parseInt(), parseFloat(), and Number() but couldn't solve the problem. It seems that the ...

What is causing my CSS grid items to overlap instead of aligning neatly in rows and columns?

I am encountering an issue with CSS grid where items are stacking on top of each other when I assign them to grid template areas. As a newcomer to CSS grid, I suspect that I may be overlooking some key principles. You can view my playground here: https:// ...