CSS Menu on Diagonal

Asked

Viewed 414 times

1

I am developing a layout of a mobile application, which will be developed in IONIC, the client sent us an example, how I would like it to be the menu of the application, as you can see in the link below:

https://dribbble.com/shots/1701001-GIF-Exercise

Could give me an idea of how to get this result, from the menu on the diagonal, taking the entire screen of the mobile phone?

  • 1

    Dude, I used a template that does something similar diagonally, see here these diagonal strokes are images used as background. maybe you can do something similar.

  • @h3nr1ke these strokes are a single SVG file, which grabs the entire screen, is already preset on it, I would need it to be independent, each menu item, as the staff posted below... Even so, thank you!

2 answers

2

You can use the CSS3 Rotate property below follows an example The effects you can use Jquery and Css @frame Animation

In your thml

<div class='celular'>
    <div class="transversal-bg">
        <div class='bar-one rotate'>

        </div>
        <div class='bar-tow rotate'>

        </div>
        <div class='bar-three rotate'>

        </div>
  </div>
  <div class='menu-setter'>

        <div class='menu-icon'>
              Icon
        </div>
        <div class='menu-icon'>
              Icon
        </div>
        <div class='menu-icon'>
              Icon
        </div>
    </div>
</div>

Css You can adapt just made a small example

.celular{float:left;width:160px;height:240px;background:pink}
.transversal-bg{float:left;width:100%;height:100%;overflow:hidden}
.rotate {
     -ms-transform: rotate(-33deg); /* IE 9 */
     -webkit-transform: rotate(-33deg); /* Safari */
     transform: rotate(-33deg); /* Standard syntax */;
     margin-left: -50px;}
.bar-one{float:let;width:160%;height:33%;background:red}
.bar-tow{float:let;width:160%;height:33%;background:orange}
.bar-three{float:let;width:160%;height:33%;background:#00bfff}
.menu-setter{position: absolute;width: 160px;}
.menu-icon{position:relative;width:100%;text-align:center;height:33%;line-
height: 480%;}

You can see an example working here

  • I repeat the same question, how could I leave the menu items, following the colored backgrounds, because as an application, they must fill 100% of the screen, both in height, and width...

  • Good you can use aniamation per frame in css, jquery or canvas Html5

1

Edith

This is the solution that I believe has the best result, has less code, uses only a linear-gradient and is easier to add new items

html, body {
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}
.container {
	width: 15%;
	height: 80%;
	overflow: hidden;
	background: linear-gradient(15deg, red 33%, yellow 33%, yellow 66%, green 66%);	
}
.container div {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	height: 33.333%;
}
<div class="container">
	<div>
		<span>item1</span>
	</div>
	<div>
		<span>item2</span>
	</div>
	<div>
		<span>item3</span>
	</div>
</div>

Can only be done with CSS using skwedY()

html, body {
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}
.container {
width: 25%;
height: 90%;
overflow: hidden;
background-color: tomato;	
}
.container div {
	width: 100%;
	background-color: gold;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	height: 33.333%;
	transform: skewY(15deg);
	transform-origin: left;
}
.container div:first-of-type {
	background-color: tomato;
}
.container div:last-of-type {
	background-color: turquoise;
}
.container div > span {
	transform: skewY(-15deg);
}
<div class="container">
	<div>
		<span>item1</span>
	</div>
	<div>
		<span>item2</span>
	</div>
	<div>
		<span>item3</span>
	</div>
</div>

  • Hugo, I found your solution very cool, however, how could you leave the menu items, following the colored backgrounds ? I made a test in the codepen, look ai https://codepen.io/d3rsonbr/pen/bLvxgb

  • I didn’t get it right, you want the text of the menu items to be tilted too? If that’s it you can by Transform: Rotate(-28deg) in div

  • that’s the idea: http://prntscr.com/ihgnt8

  • Young I do not know exactly the technique he used, but probably he was using margins to position the icons, It may also be that this menu works only for mobile screens and on the Desktop he gives another treatment pro Menu. With the answers that you have here, you can already arrive at a result very close, only complicates a little if you want it with 1200px wide and with 320px wide and each hour with a screen height. This "misalignment" of the icons is certainly not to let the top icons enter the space that has the different color below

  • Yes, this is actually just an image... it was done in photoshop this menu... I don’t know if it is possible to get in this view with CSS...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.