Show a triangle positioned on the left side of the display

Looking for help with aligning a div to the left side of the screen

CSS

#nav {
 position: fixed; 
 height: 50px; width: 50px;
 display: block;
 background-color: #000;
}

This particular div contains an icon that acts as a link

HTML

<div id="nav">icon</div>

I am trying to transform this square div into a triangle shape pointing towards the right direction

Answer №1

This website I came across is quite helpful: https://css-tricks.com/examples/ShapesOfCSS/

Creating a right-facing triangle:

#triangle-right {
    width: 0;
    height: 0;
    border-top: 50px solid transparent;
    border-left: 100px solid red;
    border-bottom: 50px solid transparent;
}

You have the flexibility to modify the border properties in order to adjust the dimensions and color of the triangle.

A demonstration similar to what you're seeking can be found here: https://jsfiddle.net/kh2xsoh2/1

HTML

<div id="nav"><span>icon</span></div>

CSS

#nav {
    width: 0;
    height: 0;
    border-top: 25px solid transparent;
    border-left: 50px solid #000;
    border-bottom: 25px solid transparent;
    position: fixed;
}

#nav span {
  position: absolute;
  line-height: 0;
  left: -45px;
  color: white;
}

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

Steps for changing the background color string in mui?

I have a component where I am trying to dynamically change the color based on the user type. The issue arises when I use gradient colors, as the transition stops working. If I stick to simple colors like blue, red, or green, it works fine. Currently, the c ...

Using ngFor in Angular 6 to create a table with rowspan functionality

Check out this functional code snippet Desire for the table layout: <table class="table table-bordered "> <thead> <tr id="first"> <th id="table-header"> <font color="white">No.</font> </th> <th id="table-hea ...

Customize your website with CSS and Bootstrap: create a transparent navbar-wrapper

Is there a way to make the menu bar background transparent without affecting the transparency of the text on the menu bar? This template is based on Twitter Bootstrap carousel. In this specific line, <div class="navbar navbar-inverse navbar-static-to ...

Extract all class elements from HTML code and save them to a text file using PHP

Is there a way to extract all span elements with the class "msgsource" from my website's HTML code and then save it as a .txt file for downloading? I tried using the following code, but it only downloads an empty text file: <?php // Grabbing conte ...

CSS for the root folder of an ASP.NET website

After deciding to venture into ASP.NET, I quickly encountered my first obstacle. The folder structure is as follows: \ ->Admin -->Admin.Aspx ->CSS -->Style.css ->Images -->bg.gif Default.aspx Default.master Both admin.aspx and ...

What is the method used by Chrome dev tools to create CSS selectors?

When setting a new style rule for an element, Chrome generates a selector that includes the entire hierarchy of elements instead of just the class name. For instance: <body> <div class="container"> <span class="helper"> ...

I can't figure out why my unslider isn't adapting to the screen size. Check out the fiddle for more details

I recently implemented unslider to create a slideshow that spans 100% of the width on my website. Everything seemed to be working fine until I tried resizing the screen, and the slides remained the same size as they were initially loaded. Here is the code ...

Having trouble placing the flash element above the HTML?

Despite my efforts to use SWFObject to embed a swf file on my webpage, it seems that the flash movie is covering some of the HTML components. Strangely enough, the HTML elements are bleeding through and appearing on top of the flash content. I've tri ...

Optimizing CSS With jQuery During Browser Resize

I am currently facing an issue with recalculating the height of the li element during window resizing or scrolling. Strangely, on page load, the height is no longer being re-calculated and set to the ul's child height. Here is the code I have written ...

Troubleshooting: Ineffective use of replace() function on input value with jQuery

Visit this link for a demo How can I update the input value based on user selection in a dropdown menu? The objective is to change the value from "service_######" to "membership##_####" when the user selects YES, but my current JavaScript code using repla ...

In IE8/IE9, Div does not surpass PDF but functions correctly on FF and Chrome

Is it possible to have a DIV displayed over a PDF document? This method seems to work with Firefox, but not with Internet Explorer 8 or 9. It's worth noting that the problem persists regardless of which PDF file is being pointed to. <html> < ...

Icon button with label positioned underneath - utilizing Font Awesome icons

I am looking to design a button that features a Font Awesome icon with text below it for a navigation menu. The goal is to achieve a layout similar to the icons found in the Microsoft ribbon. Additionally, I want to include an arrow below the button (simi ...

Guide to attaching a page content button to a fixed header

I am currently developing a webpage with a sticky header, and I want to include an animated button that moves onto the header when scrolled past. You can check out my code snippet here: https://jsfiddle.net/ykL50pjf/ The specific ID for the button is #t ...

"Utilizing an ellipsis within a span element in a table cell to achieve maximum cell

Update Note: Primarily targeting Chrome (and maybe Firefox) for an extension. However, open to suggestions for a universal solution. Additional Information Note: Discovered that lack of spaces in text for A causing overflow issues with B. Situation seem ...

Tips for concealing an entire row of a table with Jquery

I am currently working on a system that involves a table with anchor tags named original and copy in each row. By clicking on these anchor tags, we are able to update the database whether the item is an original or a copy using ajax. However, I am facing a ...

streaming an HTML5 video directly from memory source

After retrieving multiple encrypted data using ajax queries and performing necessary manipulations to turn them into a valid video, I find myself at a standstill. The binary of the video is now stored in memory, but I am unsure how to display it. To confi ...

Averages of window sizes visible without scrolling

Most designers target browsers with a resolution of 1024x768, although widths of 960 - 980px are also acceptable. (Personally, I prefer 960 for the chrome, but that's just my preference.) My query is - what window height can we generally assume for u ...

Problem encountered with modal and JavaScript: Uncaught TypeError: Unable to retrieve the property 'classList' of null

Trying to implement a modal feature for the first time but encountering an error when clicking the button. Unsure if I'm following the correct procedure as a JS beginner. Any assistance would be appreciated. ERROR { "message": "Uncaugh ...

Incorporating specific item into a table using PHP

On my page, I have 3 select forms and an addToCart button. The select forms are populated with data from the database to display products without any issue. However, when a user clicks on the addToCart button, I need to capture the selected values from t ...

How can I showcase the index of `<tr>` and `<td>` elements in a dynamically generated table

How can I print the index of table rows and data on click in javascript? <html> <head> <title>Table Creation</title> <script language="javascript" type="text/javascript"> function createTable() { ...