Perspective shadows from semi-hexagonal shapes (like flags) - html

The targeted design looks like this:
My markup and CSS can be seen in this JSFiddle: http://jsfiddle.net/n2bynh57/
HTML:
<div id="steps">
<ol class="para-small-color">
<span class="wedge"></span>
<li>
<div class="counter">1</div>
<div class="list-elem">
</div>
</li>
<li>
<div class="counter">2</div>
<div class="list-elem">
</div>
</li>
<span class="wedge"></span>
<li>
<div class="counter">3</div>
<div class="list-elem">
</div>
</li>
<li>
<div class="counter">4</div>
<div class="list-elem">
</div>
</li>
</ol>
</div>
CSS:
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#steps ol, #steps ul{
-padding-start: 0px;
-webkit-padding-start: 0px;
}
#steps ol>li:nth-child(2), #steps ol>li:nth-child(5) {
background-color: #e9e9e9;
}
#steps ol>li:nth-child(3), #steps ol>li:nth-child(6) {
margin-left: 5.6rem;
}
#steps ol>li, #steps ol>li ul li{
list-style: none;
}
#steps ol>li{
display: flex;
margin-left: 1.4rem;
}
.list-elem{
margin-left: 2rem;
}
.counter{
font: 400 4rem Arial;
padding: 10px 25px 10px 25px;
color: #a83443;
}
.wedge {
position: absolute;
display: inline-block;
width: 0px;
height: 0px;
border-style: solid;
border-width: 0 25px 8px 0;
border-color: transparent #b0b0b0 transparent transparent;
}
#steps ol li:nth-of-type(1)>.counter, #steps ol li:nth-of-type(3)>.counter {
width: 100px;
height: 100px;
background: #E9E9E9;
position: relative;
text-align: center;
}
#steps ol li:nth-of-type(1)>.counter:after, #steps ol li:nth-of-type(3)>.counter:after {
content: "";
position: absolute;
bottom: -25px;
left: 0;
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-top: 25px solid #E9E9E9;
}
I managed to get the semi-hexagonal shapes right and the corner flat shadow. But I'm not sure how the perspective flat shadows could be made. Using box-shadow doesn't seem to work right, because it cannot achieve the wedge-shaped perspective shadows. So, I suppose it might work with some border properties.

I think I found the solution. This is possible to achieve by creating the same elements again and placing the clones underneath them using z-indexed layers, then applying some transformations on these shadow-coloured shapes to make them look as if they are perspective shadows.
I will edit this post later to add the solution for reference, once I finish writing the code.
Solution: http://codepen.io/ciprianf/pen/epvvep

Related

CSS 3 special rounded border [duplicate]

This question already has answers here:
Invert rounded corner in CSS?
(10 answers)
Closed last month.
I have tried to create that rounded border corners on the bottom but I can't figure it out how to make them ....
.test {
border-bottom: 2px solid #EEF7FF;
display: inline-flex;
}
.test li {
float: left;
list-style-type: none;
}
.test li a {
text-decoration: none;
padding-left: 30px;
padding-right: 30px;
padding-top: 5px;
color: #A6B5C7;
}
<div class="" style="margin-top: 20px;">
<ul class="test" style>
<li>
<a style="border-top: 2px solid #EEF7FF;border-left: 2px solid #EEF7FF;border-right: 2px solid #EEF7FF;border-bottom: 5px solid white;color: #000000 !important;padding-bottom: 5px;vertical-align: super;border-radius: 5px 5px 0px 0px; " href="">All</a>
</li>
<li>
Solved
</li>
</ul>
</div>
Connecting border-radius from adjacent elements
Those borders might be achieved connecting the borders of the adjacent list item elements.
After finishing the demo I realized it's not the best approach to get there actually. But since it shows how to deliver an idea I think it's still worth remaining here.
Styling the active item - border-left and border-top:
I added the class active to distinguish between active and inactive navigation links.
The item with the active has only the border left and top styled:
li.active a {
position: relative;
color: black;
vertical-align: super;
border-top: solid var(--border-size) var(--border-color);
border-left: solid var(--border-size) var(--border-color);
border-radius: var(--border-radius-active) var(--border-radius-active) 0px 0px;
}
Styling the active item - border-right:
While the right border gets styled using the pseudoelement ::after positioned absolute. The reason why we couldn't style directly the right border it's because its lenght can't be the whole height since we are trying to connect with this segment the border radius coming from two different elements and if we used the whole lenght it wouldn't look right:
li.active a::after {
content:"";
background: var(--border-color);
position: absolute;
bottom: var(--border-offset-bottom);
right: 0;
height: calc(100% - var(--border-offset-top) - var(--border-offset-bottom));
width: var(--border-size);
}
Styling the next item - border-bottom:
And eventually the last portion of the line is styled by the next element:
li.active + li a {
border-bottom: solid var(--border-color) var(--border-size);
border-radius: 0 0 0 var(--border-radius-inactive);
}
Custom properties:
I encoded the core parameters as custom properties in the :root element:
--border-color: #EEF7FF;
--border-size: 1px;
--border-offset-top: 4px;
--border-offset-bottom: 2px;
--border-radius-active: 10px;
--border-radius-inactive: 3px;
The demo:
In the demo you can toggle the border color to red to better see in contrast the result:
:root{
--border-color: #EEF7FF;
--border-size: 1px;
--border-offset-top: 4px;
--border-offset-bottom: 2px;
--border-radius-active: 10px;
--border-radius-inactive: 3px;
}
.red{
--border-color: red;
}
*{
box-sizing: border-box;
}
body{
font-size: 30px;
font-family: sans-serif;
}
.test {
display: inline-flex;
}
.test li {
float: left;
list-style-type: none;
}
.test li a{
text-decoration: none;
padding-left: 30px;
padding-right: 30px;
padding-top: 5px;
padding-bottom: 5px;
color: #A6B5C7;
}
li.active a {
position: relative;
color: black;
vertical-align: super;
border-top: solid var(--border-size) var(--border-color);
border-left: solid var(--border-size) var(--border-color);
border-radius: var(--border-radius-active) var(--border-radius-active) 0px 0px;
}
li.active a::after {
content:"";
background: var(--border-color);
position: absolute;
bottom: var(--border-offset-bottom);
right: 0;
height: calc(100% - var(--border-offset-top) - var(--border-offset-bottom));
width: var(--border-size);
}
li.active + li a {
border-bottom: solid var(--border-color) var(--border-size);
border-radius: 0 0 0 var(--border-radius-inactive);
}
button{
cursor: pointer;
padding: 1em;
}
<div style="margin-top: 20px;">
<ul id="nav" class="test" style>
<li class="active">
All
</li>
<li>
Solved
</li>
</ul>
</div>
<button onclick="document.getElementById('nav').classList.toggle('red')">change color to red!</button>

CSS- can't resize text input

It was probably asked before / someone had a similar problem, but I have been searching for a long time and couldn't find any solution to my problem.
I have a div called loginBox that is centred, and has a form in it. I want the text boxes in the form to take almost the entire width of the form (It should look like google's new sign in form).
I am setting the input's margin to auto and the width to 90% using css, but for some reason it has no effect. Even when I set the width to a number (i.e 200px), the width remains unchanged.
The only way I could make it work is increase the padding of the input to 100px, but this is both not responsive, and not a good practice.
This is the code I am using:
body {
margin: 0;
background-color: #EEEEEE
}
.menu {
overflow: hidden;
background-color: #333;
position: fixed;
top: 0;
width: 100%;
z-index: 1000;
}
.menu a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.active {
background-color: #4CAF50;
}
.pageMain {
width: 100%;
padding: 16px;
margin-top: 70px;
height=1500px;
}
.loginBox {
display: table;
margin: auto;
width: 50%;
background-color: white;
box-shadow: 2px 2px lightgrey;
padding: 25px;
}
input {
margin: auto;
width=90%;
padding: 12px 20px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
<div class="menu">
<a class="active" href="index.html">Home</a>
Grades
Behavior
Homework
Learning Enviroments
Time Table
People
<a style="float: right" href="contact.html">Contact</a>
<a style="float:right" href="contact.html">Login</a>
</div>
<div class="pageMain">
<div class="loginBox">
<h3>Sign in</h3>
<h4>With your RSIS account</h4>
<form>
<input type="text" size="300" name="username" value="Email, RSIS username or id">
</form>
</div>
</div>
Screenshot of what I get right now
Fix your width. Instead of = it should be :. Your code seems fine otherwise. And width: 100% works just the way you intended.
Also, as mentioned in the comments, It should be height: 1500px; in .pageMain
body {
margin: 0;
background-color: #EEEEEE
}
.menu {
overflow: hidden;
background-color: #333;
position: fixed;
top: 0;
width: 100%;
z-index: 1000;
}
.menu a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.active {
background-color: #4CAF50;
}
.pageMain {
width: 100%;
padding: 16px;
margin-top: 70px;
height: 1500px;
}
.loginBox {
display: table;
margin: auto;
width: 50%;
background-color: white;
box-shadow: 2px 2px lightgrey;
padding: 25px;
}
input {
margin: auto;
width:100%;
padding: 12px 20px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
<div class="menu">
<a class="active" href="index.html">Home</a>
Grades
Behavior
Homework
Learning Enviroments
Time Table
People
<a style="float: right" href="contact.html">Contact</a>
<a style="float:right" href="contact.html">Login</a>
</div>
<div class="pageMain">
<div class="loginBox">
<h3>Sign in</h3>
<h4>With your RSIS account</h4>
<form>
<input type="text" size="300" name="username" value="Email, RSIS username or id">
</form>
</div>
</div>
the first look into your css file
height=1500px; // Why =, not :? <----- PageMain class
width=90%; // <---- same here in input class
change:
width=90%;
height=1500px;
to:
width:90%;
height:1500px;
also use * { box-sizing: border-box;} for remove scrollbars.

Created color boxes for a legend in HTML and CSS, but can't get two color boxes on the same line

I'm currently in the process of creating a legend for a table that has highlighted rows, but I can't seem to get two color boxes on the same li.
<ul>
<li>
<div class="input-color">
<input type="text" value="Blue/White - Alternating Rows" readonly="true" style="border:0;width:200px"/>
<div class="color-box" style="background-color: #6DC2FF;"></div>
<div class="color-box" style="background-color: white;"></div>
</div>
</li>
</ul>
With the following CSS...
ul {
list-style: none;
margin: 0;
padding: 0;
}
.input-color {
position: relative;
}
.input-color input {
padding-left: 20px;
margin-bottom: 10px;
}
.input-color .color-box {
width: 10px;
height: 10px;
display: inline-block;
background-color: #ccc;
position: absolute;
left: 5px;
top: 5px;
border: 1px solid #000;
}
Any ideas? Assuming I know how to use JSFiddle, here it is:
https://jsfiddle.net/1ywpxxks/1/
You can use CSS float: left; to prevent div from breaking lines. You can also set disply: inline-block;.

When setting padding for a div with display:table-cell, it changes padding of a neighbour div with the same display

I've created a container <div id="container"> for my content, which in return has a simple <div id="leftbar"> and <div id="content"> for the main text of the page.
I've made the <div id="container"> as a display:table in styles, and both <div id="leftbar"> and <div id="content"> as display:table-cell.
The problem I'm having now is, whenever I try to change padding on the <div id="content">, it affects padding in <div id="leftbar"> for some reason. And it applies only for the top padding.
How can I resolve this, and better yet, why is this happening? Is it because of the table structure?
Providing with code, and jsfiddle. In jsfiddle change the last padding line in CSS to see how it shifts everything in the left bar.
HTML:
<body>
<div id="wrapper">
<div id="header"><img src="http://i.imgur.com/krQBHIx.jpg" width="690" height="100"/></div>
<div id="container">
<div id="leftbar">
<ul>
<p class="heading">Navigation</p>
<li>Main</li>
<li>Articles</li>
<li>Lessons</li>
<li>About</li>
</ul>
<p class="heading" style="background: #bb0;">Subscribe</p>
<form action="subscribe.php" method="POST" name="form1">
Subscribe to our RSS feed and get all the fresh news and articles directly in your mail box!<br /><br />
<label><p>Enter your name:</p><input type="text"/></label>
<label><p>Enter your e-mail:</p><input type="text"/></label>
<input type="submit" name="submit" value="Send!"/>
</form>
</div>
<div id="content">
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.
</div>
</div>
<div id="footer"><img src="http://i.imgur.com/2GzQuoo.jpg" width="690" height="18"/></div>
</div>
</body>
CSS:
/* Styles */
*
{
padding: 0;
margin: 0;
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
font: 14px Verdana, Tahoma, sans-serif;
}
*:before, *:after {
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
}
a
{
color: #000;
text-decoration: none;
}
body
{
background: #606B79;
}
p
{
font: 14px Tahoma, Verdana, sans-serif;
}
#wrapper
{
width: 690px;
margin: 10px auto;
}
#header img
{
display: block;
height: 100%;
}
#footer img
{
border: 1px solid black;
border-top: none;
display: block;
}
#container
{
display: table;
width: 100%;
border-left: 1px solid black;
border-right: 1px solid black;
background: #fff;
}
#leftbar
{
display: table-cell;
width: 184px;
border-right: 2px solid black;
height: 100px;
padding: 5px;
}
#leftbar ul
{
list-style: none;
margin-bottom: 15px;
}
.heading
{
text-align: center;
background-color: #a22;
color: #fff;
padding: 3px;
margin-bottom: 7px;
}
#leftbar ul li
{
border: 1px solid gray;
border-bottom: none;
}
#leftbar ul li:last-child
{
border: 1px solid gray;
}
#leftbar a
{
display: block;
padding: 2px 4px;
}
#leftbar a:hover
{
background: #ccc;
}
#leftbar form
{
border: 1px solid gray;
padding: 10px;
text-align: justify;
}
#leftbar form input
{
width: 149px;
margin: 3px 0;
}
#leftbar form input[type="submit"]
{
height: 25px;
background: #ccc;
margin-top: 20px;
}
#content
{
display: table-cell;
width: 506px;
text-align: justify;
padding: 25px;
}
jsfiddle: http://jsfiddle.net/9Qtpj/
Help me, please?
The content in your #leftbar div is aligned to the baseline. To fix your current html/css change the following:
#leftbar
{
vertical-align: top;
display: table-cell;
width: 184px;
border-right: 2px solid black;
height: 100px;
padding: 5px;
}
BUT! You really should be using another method for this. Displaying non-table elements as tables can have its issues, and isn't needed anymore.
Start learning about flexbox [the latest and greatest in web layout] - http://css-tricks.com/snippets/css/a-guide-to-flexbox/ and use floats as a fallback [see #AlexPrinceton's answer].
Try to change your CSS styles. Don use display:table for aligning elements if you can use "float"
Here is your code
CSS
#container {
width:100%;
overflow:hidden
}
#content {
float:right;
width:506px;
padding:25px;
}
#leftbar {
width:184px;
float:left;
padding:5px;
}

How can I align buttons to the center of the navbar

I'm using jQuery Mobile to create this navbar but I can't align the buttons to the center.
Here is my code:
<footer data-role="footer" data-position="fixed" data-theme="b">
<nav data-role="navbar">
<ul>
<li>Record</li>
<li>Upload</li>
<li>Refresh</li>
<li>Clear</li>
</ul>
</nav>
</footer>
I have tried with data-grid="c" but it's not working.
Any idea?
I haven't add any CSS style to this project
This is the compiled jQuery Mobile:
Block (each block inside the navbar):
.ui-grid-c > .ui-block-a, .ui-grid-c > .ui-block-b, .ui-grid-c > .ui-block-c, .ui-grid-c > .ui-block-d {
width: 25%;
}
ul.ui-grid-a, ul.ui-grid-b, ul.ui-grid-c, ul.ui-grid-d, ul.ui-grid-solo, li.ui-block-a, li.ui-block-b, li.ui-block-c, li.ui-block-d, li.ui-block-e {
margin-left: 0;
margin-right: 0;
padding: 0;
list-style: none;
}
.ui-block-a {
clear: left;
}
.ui-block-a, .ui-block-b, .ui-block-c, .ui-block-d, .ui-block-e {
margin: 0;
padding: 0;
border: 0;
float: left;
min-height: 1px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
li {
display: list-item;
text-align: -webkit-match-parent;
}
.ui-navbar ul {
list-style: none;
}
ul.ui-grid-a, ul.ui-grid-b, ul.ui-grid-c, ul.ui-grid-d, ul.ui-grid-solo, li.ui-block-a, li.ui-block-b, li.ui-block-c, li.ui-block-d, li.ui-block-e {
list-style: none;
}
ul, menu, dir {
list-style-type: disc;
}
.ui-bar-b, .ui-page-theme-b .ui-bar-inherit, html .ui-bar-b .ui-bar-inherit, html .ui-body-b .ui-bar-inherit, html body .ui-group-theme-b .ui-bar-inherit {
color: #fff /*{b-bar-color}*/;
text-shadow: 0 /*{b-bar-shadow-x}*/ 1px /*{b-bar-shadow-y}*/ 0 /*{b-bar-shadow-radius}*/ #111 /*{b-bar-shadow-color}*/;
font-weight: bold;
}
.ui-overlay-a, .ui-page-theme-a, .ui-page-theme-a .ui-panel-wrapper {
color: #333 /*{a-page-color}*/;
text-shadow: 0 /*{a-page-shadow-x}*/ 1px /*{a-page-shadow-y}*/ 0 /*{a-page-shadow-radius}*/ #f3f3f3 /*{a-page-shadow-color}*/;
}
.ui-overlay-a, .ui-page-theme-a, .ui-page-theme-a .ui-panel-wrapper {
color: #333 /*{a-page-color}*/;
text-shadow: 0 /*{a-page-shadow-x}*/ 1px /*{a-page-shadow-y}*/ 0 /*{a-page-shadow-radius}*/ #f3f3f3 /*{a-page-shadow-color}*/;
}
body, input, select, textarea, button, .ui-btn {
font-size: 1em;
line-height: 1.3;
font-family: sans-serif /*{global-font-family}*/;
}
Icon
.ui-btn-icon-notext:after, .ui-btn-icon-top:after, .ui-btn-icon-bottom:after {
left: 50%;
margin-left: -11px;
}
.ui-btn-icon-notext:after, .ui-btn-icon-left:after, .ui-btn-icon-right:after {
top: 50%;
margin-top: -11px;
}
.ui-btn-icon-left:after, .ui-btn-icon-right:after, .ui-btn-icon-top:after, .ui-btn-icon-bottom:after, .ui-btn-icon-notext:after {
content: "";
position: absolute;
display: block;
width: 22px;
height: 22px;
}
.ui-btn-icon-left:after, .ui-btn-icon-right:after, .ui-btn-icon-top:after, .ui-btn-icon-bottom:after, .ui-btn-icon-notext:after {
background-color: #666 /*{global-icon-color}*/;
background-color: rgba(0,0,0,.3) /*{global-icon-disc}*/;
background-position: center center;
background-repeat: no-repeat;
-webkit-border-radius: 1em;
border-radius: 1em;
}
All you need is, to force button inside each block to fill width completely.
.ui-navbar li a {
width: 100% !important;
}
Demo
You may want to look at using vertical-align
The vertical-align CSS property specifies the vertical alignment of an
inline or table-cell box.
Try:
a.ui-btn{
vertical-align:middle;
}
Although this is on the assumption you dont have other style settings which may interfere, its hard to say without having your CSS. You may need to also set margin:0; or remove any paddingfrom the containing li
Try margin: 0 auto in your css