Need help getting an effect on a header and with a button - html

I am trying to get a certain effect on a header for a mockup. It has white glow almost not noticeable. You will see it in this picture i provide behind the title and sub title. How can i get that glow effect with css? I do have a header with the entire thing but is that a good idea to use an image for an entire header? Also i want those two lines near the subtitle. Is it possible to code those lines? And last, the button "order now", will that be possible to make with css or should i just use an image of that and link it?
mockup
jsfiddle - http://jsfiddle.net/ezdr3xdg/1/ [what i currently have]
<header>
<h1>Taffies Cupcakes</h1>
<h2>Fresh and tasty</h2>
</header>
body{
background-color:#e7d2c9;
}
header h1{
font-family:georgia;
font-size:46px;
color:#784f3d;
text-align:center;
margin-top:50px;
}
header h2{
font-family:segoe script;
font-size:32px;
color:#846a5f;
text-align:center;
}

All of this is possible to do in CSS 3, I wouldn't recommend it though. Using an image for the button and the header is the best idea if you want it to look the same in all browsers. If you want to do it in CSS anyway try this:
HTML:
<header>
<div class="shadow"></div>
<h1>Taffies Cupcakes</h1>
<h2><div class="line"></div>Fresh and tasty<div class="line"></div></h2>
</header>
CSS:
header > .shadow {
width: 0px;
height: 0px;
margin: 0px 50%;
box-shadow: 0px 0px 200px 100px white;
}
header h2 > .line {
height: 1px;
width: 100px;
margin: 5px 20px;
background-color: #846a5f;
display: inline-block;
vertical-align: middle;
}
As the other answers have mentioned, radial-gradient is probably the way to go here. Just apply it to the header element instead of using my version with box-shadow (which might be a little hacky to some).
Update for the button:
HTML:
<button class="special"><div class="icon"></div><div class="headline">ORDER NOW</div><div class="description">We deliver in 24 hours</div></button>
CSS:
button.special {
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #784f3d), color-stop(1, #846a5f) );
background:-moz-linear-gradient( center top, #784f3d 5%, #846a5f 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#784f3d', endColorstr='#846a5f');
background-color:#784f3d;
color: #e7d2c9;
text-align: left;
border: 0;
outline: 0;
border-radius: 5px;
height: 42px;
}
button.special > .icon {
width: 27px;
height: 27px;
/*background-image: url('triangle-button.png')*/
position: absolute;
margin: 5px;
}
button.special > .headline {
margin-left: 42px;
font-size: 18px;
}
button.special > .description {
margin-left: 42px;
font-size: 12px;
}
http://jsfiddle.net/ezdr3xdg/17/

Use CSS radial-gradient()
DEMO 1:
body {
height: 100vh;
background-color: #e7d2c9;
background-image: -webkit-radial-gradient(center top, ellipse farthest-corner, #fff 0%, #e7d2c9 50%);
}
DEMO 2:
body{
height:100vh;
background-color:#e7d2c9;
background-image: -webkit-radial-gradient(center top, ellipse farthest-corner, #fff 0%, #e7d2c9 100%);
}
DEMO 3:
body {
height: 100vh;
background-color: #e7d2c9;
position:relative;
}
body:after {
content: '';
position: absolute;
left: 50%;
top: -150px;
margin-left: -100px;
width: 200px;
height: 200px;
border-radius: 50%;
z-index:-1;
background: rgba(255, 255, 255, 0.42);
box-shadow: 0 0 40px 64px rgba(255, 255, 255, 0.42);
}

I have update your jsfiddle with a starting template of sorts. Its CSS# gradients and border-radius. http://jsfiddle.net/ezdr3xdg/7/
the button:
<div id="order_now">
<div id="triangle-right"></div>
<div id="text">
ORDER NOW
<div id="sub_order">we deliver in 24hours</div>
</div>
</div>
CSS:
The Button:
#order_now{
background: linear-gradient(#846a5f, brown);
width: 200px;
border-radius: 5px;
padding: 5px;
color: white;
font-size: 12pt;
font-weight: bold;
}
#sub_order{
font-size: 10pt;
font-style: italic;
}
#triangle-right {
width: 0;
height: 0;
border-top: 25px solid transparent;
border-left: 50px solid white;
border-bottom: 25px solid transparent;
display: inline-block;
}
#text{
display: inline-block;
}
The Background:
body{
background:linear-gradient(to right, red, blue, red);
}
this should be enough to get you started.

Related

Inner rounded shadows inside div

I have a div which looks something like this:
.box{
box-sizing: border-box;
border: solid 0.01rem #2e2e2e;
border-radius: 3px;
width:100px;
height:100px;
background:red;
}
<div class="box"/>
And I'm trying to achieve this effect. How can I make this box look with such shadows from the inside of the div?
linear gradient
blur filter
absolute positioning
pseudo-elements
flexbox
.box {
box-sizing: border-box;
border-radius: 10%;
width: 100px;
height: 100px;
background: linear-gradient(270deg, red, #c10606);
position: relative;
}
.box:before {
position: absolute;
content: '';
top: 10%;
right: 10%;
bottom: 10%;
left: 10%;
background: linear-gradient(90deg, red, #c10606);
border-radius: 12%;
filter: blur(1px); /* optional for a softer effect */
}
/* optional layout and styling for box contents */
.box {
display: flex;
align-items: center;
text-align: center;
font-family: arial;
color: #ddd;
font-weight: bold;
}
.box * {
position: relative; /* puts interior content over the pseudo-element */
}
<div class="box">
<span>Interior content</span>
</div>
CSS box-shadow
I think the answer posted by #isherwood works as the best one for your use-case. But, there is a way to make the shadow show on the inside of the element by setting the last parameter of box-shadow as inset.
There are a few catches for this solution though. A few things which I could not achieve:
I am unable to implement linear gradient to the shadow.
I am unable to give a border-radius to the inner boundary of the shadow.
div.box {
background: linear-gradient(90deg, hsl(26, 68%, 26%), hsl(26, 68%, 45%));
height: 100px;
width: 100px;
box-shadow: 0 0 0 12px hsl(26, 68%, 35%) inset;
border-radius: 10px;
}
<div class="box"></div>
Reference: How to create an inner shadow using CSS
Well, I edited your code. Here is the demo.
Basically, I added one more div and added some style. Hope it will give you an idea.
Also, I added a snippet down below:-
.box {
box-sizing: border-box;
border: solid 0.01rem #2e2e2e;
border-radius: 15px;
width: 100px;
height: 100px;
background: red;
padding: 10px 0px 10px 0px;
}
.inner-div {
box-sizing: border-box;
border-radius: 15px;
width: 78px;
height: 78px;
background: #ee1717;
margin: 0 auto;
}
<div class="box"/>
<div class="inner-div"></div>
<div>

How to achieve this effect with css

I would to be able to create this effect shown here:
Where a block of a section is pushed up on top of another section, it's often times a block of text that does it, but I couldn't find a good example of it so my s/s uses an image.
I know this is a very common effect but I don't know its name so I am struggling to find guides on it. If someone can just give me the name of this CSS effect that'd be awesome so I can search for it on the web and learn how to achieve this effect.
I used a negative margin on the overlaying element: https://jsfiddle.net/2ezwtj1j/3/
html
<div id="landing"></div>
<div id="card">
<h1>My Sick Header</h1>
<p>My amazing content.</p>
</div>
css
#landing {
margin:0px;
padding-bottom: 200px;
background: #7703a5;
background: -moz-linear-gradient(-45deg, #7703a5 0%, #00c7ef 100%);
background: -webkit-linear-gradient(-45deg, #7703a5 0%,#00c7ef 100%);
background: linear-gradient(135deg, #7703a5 0%,#00c7ef 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7703a5', endColorstr='#00c7ef',GradientType=1 );
}
#card {
padding: 1vw;
box-shadow: 0 1px 3px 0 #D4D4D5, 0 0 0 1px #D4D4D5;
width:80%;
height:300px;
background:#fff;
margin: 0 auto;
margin-top:-100px;
font-family: sans-serif;
}
In their case, they used absolute positioning. You can also move an element up (into another section) using transform: translate();. Below is an example.
BTW, you can always use your dev tools to inspect the page and see what CSS they used to position that element. Here is the URL for that layout in your screenshot. http://unbounce.com/landing-page-template/mova/
* {margin:0;}
section {
background: red;
height: 100vh;
position: relative;
}
section:nth-child(2) {
background: blue;
}
h1 {
background: #fff;
position: absolute;
top: -.5em;
width: 50%;
text-align: center;
left: 50%;
transform: translateX(-50%);
}
<section></section>
<section><h1>hello</h1></section>
You can achieve this by using the negative top margin take a look:
https://jsfiddle.net/7Lb5x1he/
HTML
<div></div>
<div></div>
<div></div>
CSS
div {
height: 200px;
border: 1px solid black;
}
div:nth-of-type(1) {
background: lightblue;
}
div:nth-of-type(2) {
background: grey;
}
div:nth-of-type(3) {
width: 60%;
margin: -300px auto 0 auto;
background: white;
}

multiple background colors for an image

What I am looking to achieve is to display an image with a transparent background layer, this image would sit over a background which would have a white border and gray box centred in the image area.
Basically to give the image a partial gray background, then to leave the rest white, to give the appearance of the image to "float" over the gray background as well as allow me to make simple css changes to change the background verses having to redo the images to change the look.
this is the css I have tried:
.borderlist img {
text-align:center;
vertical-align:middle;
background:
linear-gradient
(255,255,255, 0.9),
url('../images/gray.png') no-repeat;
max-width: 100%;
height:auto;
}
And the html:
<span class="borderlist"><img src="images/bounty.png" alt="BOUNTY" title=" BOUNTY " width="225" height="155"></span><br>BOUNTY
I removed the underline from the <a> because it creates a weird underline on the <br>. If you want the text to be underlined, you could throw it in a <span> with a class that tells it to have it. but this is what I got. Let me know if you're needing it to do something different.
.overflowing-img {
display: inline-block;
text-align: center;
text-decoration: none;
}
.undrline {
text-decoration: underline;
}
.borderlist {
text-align: center;
}
.borderlist img {
text-align:center;
vertical-align:middle;
background-image: linear-gradient(rgba(160,160,160, 0.5), rgba(160,160,160, 0.5));
background-repeat: no-repeat;
background-size: 80% auto;
background-position: center center;
}
<a href="http://www.domain.com/bounty.html" class="overflowing-img">
<span class="borderlist">
<img src="http://pngimg.com/upload/gift_PNG5950.png" alt="BOUNTY" title=" BOUNTY " width="225" height="155">
</span>
<br>
<span class="undrline">BOUNTY<span>
</a>
I used a different image, but is this what you are attempting to achieve?
.borderlist img {
width: 200;
height: 100;
}
.borderlist {
width: 225px;
height: 125px;
text-align: center;
vertical-align: middle;
background: linear-gradient(to bottom, #c8c8c8, #ffffff);
margin: auto;
}
.whiteBorder {
width: 255px;
height: 155px;
background-color: #ffffff;
text-align: center;
}
<div class="whiteBorder">
<div class="borderlist">
<a href="http://www.domain.com/bounty.html">
<img src="http://en.wikipedia.org/static/images/project-logos/enwiki.png" alt="BOUNTY" title="BOUNTY">
<br>BOUNTY</a>
</div>
</div>
Try doing using :before in your css to overlay the image on top of a div.
div{
width: 200px; height: 200px;
background-color: lightgray;
box-sizing: border-box;
border: 20px solid white;
position: relative;
}
div:before{
content: "";
display: block;
margin: -20px;
width: 200px;
height: 200px;
background-image: url('https://i.stack.imgur.com/eLzG5.png');
background-size: contain;
background-repeat: no-repeat;
}
<div></div>
Lets go very simple first:
You can't move the image to left by changing css though
.borderlist {
background: grey;
border: 60px solid white;
box-sizing: border-box;
width: 260px;
}
<div class="borderlist">
<img src="https://s9.postimg.org/d0odjmlcv/dwa.png" height="100px" width="150px" />
</div>
You can do this too, create a container div, inside, create the grey div, then float the image above the grey div, like this (I think this is the best):
.borderlist {
padding: 5%;
background: white;
width: 160px;
height: 120px;
position: relative;
}
.grey {
position: absolute;
background: grey;
width: 130px;
height: 90px;
margin: 10px;
}
.float {
position: absolute;
}
<div class="borderlist">
<div class="grey">
</div>
<img class="float" src="https://s9.postimg.org/d0odjmlcv/dwa.png" height="100px" width="150px" />
</div>
Feel free to change and play around to understand it properly
If you're OK with using a mask (white colored background covering the edges), you could use multiple backgrounds coupled with a background color. (credit to user Dave Cripps for the demo image that I shamelessly stole from his demo for mine.)
a {
text-align:center;
display:inline-block;
}
.borderlist {
display:inline-block;
text-align:center;
vertical-align:middle;
background:
linear-gradient(to right, white 15%, transparent 15%, transparent 85%, white 85%), linear-gradient(to bottom, white 15%, transparent 15%, transparent 85%, white 85%);
background-color: #eee;
transition: background-color 0.4s;
}
a:hover .borderlist {
background-color: #5C5;
}
.borderlist img {
height:auto;
}
<span class="borderlist"><img src="http://en.wikipedia.org/static/images/project-logos/enwiki.png " alt="BOUNTY" title=" BOUNTY " width="225" height="155"></span><br>BOUNTY

Button with partial border on top and bottom

Hi all,
I would like to insert a <button> in my code that has a gap in border-top and border-bottom. I have seen some examples where it is possible to remove a part with it, but it's not exactly what I am looking for. Do you have an idea on how to get something like the above mentioned picture?
Thanks in advance for your replies!
EDIT:
I add more information: the best is that the background of the button is transparent and that the border-size is customisable.
Use pseudo elements
.brd {
font-size: 30px;
padding: 4px 20px;
position: relative;
border: none;
background-color: white;
}
.brd:before,
.brd:after {
content: ' ';
position: absolute;
border: 1px solid black;
top: 0;
bottom: 0;
width: 10px;
}
.brd:before {
border-right: 0;
left: 0;
}
.brd:after {
border-left: 0;
right: 0;
}
<span class="brd">Title</span>
<button class="brd">Title</button>
Another possible solution is to use gradient as border-image. Look at the snippet below
.box{
display:inline-block;
margin: auto;
padding: 10px;
border: 3px solid transparent;
-moz-border-image: -moz-linear-gradient(to right, #aaa 10%, #fff 10%, #fff 90%, #aaa 90%);
-webkit-border-image: -webkit-linear-gradient(to right, #aaa 10%, #fff 10%, #fff 90%, #aaa 90%);
border-image: linear-gradient(to right, #aaa 10%, #fff 10%, #fff 90%, #aaa 90%);
border-image-slice: 1;
}
<div class="box" >TITLE HERE</div>
If you want the top and bottom border parts to be exactly X pixels, you can change the percents with pixels like this:
border-image: linear-gradient(to right, #aaa 20px, #fff 20px, #fff calc(100% - 20px), #aaa calc(100% - 20px));
A simple way would be using a custom made image as the background of your button, tho it wouldn't scale well on different screen sizes.
Another idea would be to have a div underneath with a normal border, and then your smaller button on top of it, with the same height and a white border, so as to hide the top and bottom part.
I've created a JSFiddle for you: enter link description here
HTML:
<div class="back-with-border">
<div class="front-no-border">
Title Here
</div>
</div>
CSS:
.back-with-border{
border:1px solid gray;
width:200px;
height:100px;
position: relative;
}
.front-no-border{
display:flex;
justify-content:center;
align-items:center;
border:0px;
background-color:white;
position: absolute;
width:110px;
height:110px;
top:-1px;
left:45px
}
Check this [JSFiddle][1], hope this will solve your problem
body {
background-color: white;
}
.parent {
border: 1px solid black;
width: 200px;
height: 100px;
position: relative;
background-color: white;
}
.child {
display: flex;
justify-content: center;
align-items: center;
border: 0px;
background-color: white;
position: absolute;
width: 150px;
height: 103px;
top: -1px;
left: 25px
}
<div class="parent">
<div class="child">
Write your text here
</div>
</div>
[1]: https://jsfiddle.net/anshul24mehta/eocst0uv/3/

centering a few links inside a container that is 1000% width?

I have a list of nav items that I want to eventually be able to swipe through so I've created an unordered list which initially has a width of 1000% for testing and the links are positioned inline-block. This works well if there are enough links to fill the whole width of the page but if there is only a few links they get stuck to the left of the nav, ideally what I would like to do is have these centered. Ive tried adding text-align: center to the nav but this centers the links in the 1000% wide space and not the 100% page width. Can anyone recommend a solution as I thought this may be achievable with just CSS
JS Fiddle (with just a few links): http://jsfiddle.net/HS4VE/
CSS
nav {
padding: 10px 0;
overflow: hidden;
text-align: center;
border: 1px solid #cccccc;
border-left: 0;
border-right: 0;
}
nav li {
display: inline-block;
vertical-align: middle;
zoom: 1;
margin-right: -4px;
position: relative;
}
nav a {
color: white;
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #454545), color-stop(100%, #363636));
background-image: -webkit-linear-gradient(#454545, #363636);
background-image: -moz-linear-gradient(#454545, #363636);
background-image: -o-linear-gradient(#454545, #363636);
background-image: linear-gradient(#454545, #363636);
font-size: 14px;
height: 25px;
line-height: 25px;
padding: 0 15px;
width: 186px;
display: block;
border-right: 1px solid white;
text-align: center;
}
nav a.is-active {
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fe57ae), to(#fe329b));
background-image: -webkit-linear-gradient(#fe57ae, #fe329b);
background-image: -moz-linear-gradient(#fe57ae, #fe329b);
background-image: -o-linear-gradient(#fe57ae, #fe329b);
background-image: linear-gradient(#fe57ae, #fe329b);
}
.inner {
width: 1000%;
}
Use this:
.inner {
white-space:nowrap;
max-width: 1000%;
}
Demo: http://jsfiddle.net/HS4VE/3/