Child element only covering parent image - html

I have a menu where I want to have an active state and a hover state of the menu items. My problem is illustrated best in the two images. The green background color should only cover the dark orange area (Which is an image).
This is my menu now:
And this is how I want it to be:
Which way is best to cut the bottom of the green element to get this effect?
My code so far in JSFIDDLE:
http://jsfiddle.net/HC5qC/
CSS:
nav ul {
padding: 0;
list-style-type: none;
position: absolute;
right: 96px;
top: 37px;
}
nav li {
float: left;
}
nav a {
text-decoration: none;
font-weight: 400;
font-size: .9375em;
text-transform: uppercase;
letter-spacing: 0.05em;
color: #fff;
padding: 54px 15px 65px 15px;
overflow: hidden;
}
.current-menu-item a,
.current-menu-item a:hover {
background: #79bd8f; /* Old browsers */
background: -moz-linear-gradient(top, #79bd8f 30%, #00a388 99%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(30%,#79bd8f), color-stop(99%,#00a388)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #79bd8f 30%,#00a388 99%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #79bd8f 30%,#00a388 99%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #79bd8f 30%,#00a388 99%); /* IE10+ */
background: linear-gradient(to bottom, #79bd8f 30%,#00a388 99%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#79bd8f', endColorstr='#00a388',GradientType=0 ); /* IE6-9 */
}
nav a:hover {
background: #6b1600;
background: rgba(107, 22, 0, 0.2);
}

I wonder if something like this FIDDLE might get you started.
I'll play around with it a bit more, to see how close we might get to what you want.
But the concept is to put an :after or :before, or an absolutely positioned "overlay" and be able to click to boxes behind.
CSS
.selector {
width: 295px;
height: 100px;
overflow: hidden;
background-color: transparent;
position: relative;
}
.button1 {
float: left;
width: 32%;
height: 100%;
border: 1px solid white;
background-color: blue;
}
.selector:after {
content: '';
width: 300px;
height: 30px;
position: absolute;
top: 85px;
left: 0px;
transform: rotate(-3deg);
background-color: red;
}

Related

How do I make the text over an image to be responsive

I am having an issue with making my text responsive with the image its placed with, specifically in mobile view.
Here is how the module looks in desktop/tablet view:
And here is how it looks in mobile view:
The issue here is that I want the image boxes in mobile view to be center aligned. However, when I centre align the div with the images, the text is still placed on the left side, and not being responsive.
I am not entirely sure how to adjust my code to make the text responsive with the images, but here is the code that I have for these respective elements.
.cssHotelBox {
position: relative;
}
.pickgradient{
position:relative;
display:inline-block;
}
.pickgradient:after {
content:'';
position:absolute;
top:0;
margin-top: 99px;
left: 1px;
width:221px; height:50%;
display:inline-block;
background: -moz-linear-gradient(top, rgba(0,0,0,0) 0%, rgba(0,0,0,0.70) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0.70)), color-stop(100%,rgba(0,0,0,0))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.70) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.70) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.70) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,0.70) 100%); /* W3C */
}
.cssHotelImage {
height: 160px;
width: 223px;
border: solid 1px #FFF;
margin-top: 40px;
}
.cssHotelText {
color: #FFF;
font-size: 14px !Important;
position: absolute;
top: 160px;
left: 8px;
}
.cssHotelCity {
color: #FFF;
font-family: inherit;
font-size: 11px !Important;
position: absolute;
top:180px;
font-weight: 100 !Important;
display: flex;
align-items: center;
align-content: center;
justify-content: center;
flex-grow: 1;
flex-shrink: 1;
flex-basis: auto;
}
.starRating {
display:inline-block;
width:60px;
height:11px;
background:transparent url(../images/star-sprites.png) no-repeat scroll;
margin-left: 6px;
margin-right: 2px;
}
When I make .cssHotelBox have the text-align: center, this is how it shows up:
I would like the text to be responsive within the image after:
#media (max-width: 768px) {
}
Is there any way I can fix the issue with the text? Thanks.
You should wrap the image and the text within the same container

Create a responsive CSS button with arrow

I'm trying to create a responsive button from a photoshop mockup in HTML and CSS. Here is the button mockup:
I'm struggling with how to get the arrow in the white space and to stay there through different screen sizes.
I created the color separation through a gradient, like this:
HTML
<button> All Team Members </button>
CSS
button {
/* Permalink http://colorzilla.com/gradient-editor/#990033+0,990033+50,990033+86,ffffff+86,ffffff+100 */
width: 70%;
font-size: .6em;
font-size: 3.4vw;
padding: 2%;
color: #ffffff;
outline-color: #990033;
background: rgb(153,0,51); /* Old browsers */
background: -moz-linear-gradient(left, rgba(153,0,51,1) 0%, rgba(153,0,51,1) 50%, rgba(153,0,51,1) 86%, rgba(255,255,255,1) 86%, rgba(255,255,255,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(153,0,51,1)), color-stop(50%,rgba(153,0,51,1)), color-stop(86%,rgba(153,0,51,1)), color-stop(86%,rgba(255,255,255,1)), color-stop(100%,rgba(255,255,255,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, rgba(153,0,51,1) 0%,rgba(153,0,51,1) 50%,rgba(153,0,51,1) 86%,rgba(255,255,255,1) 86%,rgba(255,255,255,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, rgba(153,0,51,1) 0%,rgba(153,0,51,1) 50%,rgba(153,0,51,1) 86%,rgba(255,255,255,1) 86%,rgba(255,255,255,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, rgba(153,0,51,1) 0%,rgba(153,0,51,1) 50%,rgba(153,0,51,1) 86%,rgba(255,255,255,1) 86%,rgba(255,255,255,1) 100%); /* IE10+ */
background: linear-gradient(to right, rgba(153,0,51,1) 0%,rgba(153,0,51,1) 50%,rgba(153,0,51,1) 86%,rgba(255,255,255,1) 86%,rgba(255,255,255,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#990033', endColorstr='#ffffff',GradientType=1 ); /* IE6-9 */
}
And it currently looks like this:
What is the best way to move forward? I wondered if I should just use screenshots of the button from the mockup, or if I should make it in CSS. How can I make the button look like this and be responsive?
Use pseudo elements :before and :after, to make the background and the arrow. Use Font Awesome etc if you need a different shape of arrow.
button {
font-size: 3vw;
padding: 2vw;
color: #ffffff;
background: #903;
border: 0;
position: relative;
padding-right: 8vw;
}
button:before {
content: '';
width: 6vw;
position: absolute;
right: 0;
top: 0;
bottom: 0;
background: white;
border: 1px solid #903;
}
button:after {
content: '❯';
position: absolute;
right: 2vw;
color: #903;
}
<button>All Team Members</button>
jsfiddle
try this:
.btn {padding:10px 40px 10px 20px;
width:70%;
border-radius:3px;
border:2px solid inherit;
border-color: #eeeeee;
background-color:rgb(153,0,51);
background-position:center right;
background-repeat:no-repeat;
text-align:center;
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#990033', endColorstr='#ffffff',GradientType=1 ); /* IE6-9 */
font-size: .6em
}
.white_txt {color:#ffffff!important;}
.purple_btn {border:2px solid #eeeeee;border-radius:3px;}
<div class="purple_btn btn">
<div class="white_txt">All Team Members</div>
</div>

How to create diagonal gradient from corner to corner?

I have columns with gradients. Need create a gradient that will start from top right corner to bottom left corner, but corners of a gradient are clipped.
It looks ugly and and corners of gradients are not linked. I tried use background image but it is bad working on mobile devices.
<section class="slider">
<div class="container slider-menu">
<div class="col-lg-5ths col-md-5ths col-sm-5ths col-xs-4"><img src="http://rustypepper.me/production/img/icon-2.png" alt="Шарики" class="img-responsive">
<p>
Lorem <br> Ipsum
</p>
</div>
// ........ 14 same columns
</section>
.slider-menu div {
background: #006bac;
position: relative;
margin-bottom:5px;
height: 240px; }
.slider-menu div img {
position: relative;
z-index: 999; }
.slider-menu div:after {
content: "";
position: absolute;
top: 0;
left: 0;
opacity: 0.1;
width: 100%;
height: 100%;
z-index: 1;
background: black;
/* Old browsers */
background: -moz-linear-gradient(45deg, black 0%, white 51%, black 51%, white 100%);
/* FF3.6+ */
background: -webkit-gradient(linear, left bottom, right top, color-stop(0%, black), color-stop(51%, white), color-stop(51%, black), color-stop(100%, white));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(45deg, black 0%, white 51%, black 51%, white 100%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(45deg, black 0%, white 51%, black 51%, white 100%);
/* Opera 11.10+ */
background: -ms-linear-gradient(45deg, black 0%, white 51%, black 51%, white 100%);
/* IE10+ */
background: linear-gradient(45deg, black 0%, white 51%, black 51%, white 100%);
/* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#000000', endColorstr='#ffffff',GradientType=1 );
/* IE6-9 fallback on horizontal gradient */ }
.slider-menu img {
display: block;
margin: 0 auto; }
.slider-menu p {
text-align: center;
color: #fff;
margin-top: 20px; }
http://codepen.io/lifetowin/pen/PqByRK/
An alternate solution is to set the angle with symbolics names
background: linear-gradient(to top right, black 0%, white 51%, black 51%, white 100%);
This way, the gradient will adapt itself to the container dimensions, instead of adapting the dimensions to the gradient angle
You have used 45 degree gradient so the height and the width of cells must be equal. Yours are not. So if you make the width and height are equal then it will be ok. And i changed the gradient stop %51 to %50
.slider-menu div {
background: #006bac;
position: relative;
margin-bottom:5px;
height: 228px; }
.slider-menu div img {
position: relative;
z-index: 999; }
.slider-menu div:after {
content: "";
position: absolute;
top: 0;
left: 0;
opacity: 0.1;
width: 100%;
height: 100%;
z-index: 1;
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#000000+0,ffffff+52,000000+52,ffffff+100,000000+100,ffffff+100 */
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#000000+0,ffffff+51,000000+51,ffffff+100 */
background: black;
/* Old browsers */
background: -moz-linear-gradient(45deg, black 0%, white 50%, black 50%, white 100%);
/* FF3.6+ */
background: -webkit-gradient(linear, left bottom, right top, color-stop(0%, black), color-stop(50%, white), color-stop(50%, black), color-stop(100%, white));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(45deg, black 0%, white 50%, black 50%, white 100%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(45deg, black 0%, white 50%, black 50%, white 100%);
/* Opera 11.10+ */
background: -ms-linear-gradient(45deg, black 0%, white 50%, black 50%, white 100%);
/* IE10+ */
background: linear-gradient(45deg, black 0%, white 50%, black 50%, white 100%);
/* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#000000', endColorstr='#ffffff',GradientType=1 );
/* IE6-9 fallback on horizontal gradient */ }
.slider-menu .row {
padding: 0px; }
.slider-menu img {
display: block;
margin: 0 auto; }
.slider-menu p {
text-align: center;
color: #fff;
margin-top: 20px; }
.col-xs-5ths,
.col-sm-5ths,
.col-md-5ths,
.col-lg-5ths {
position: relative;
min-height: 1px;
padding-right: 10px;
padding-left: 10px; }
.col-xs-5ths {
width: 20%;
float: left; }
#media (min-width: 768px) {
.col-sm-5ths {
width: 20%;
float: left; } }
#media (min-width: 992px) {
.col-md-5ths {
width: 20%;
float: left; } }
#media (min-width: 1200px) {
.col-lg-5ths {
width: 20%;
float: left; } }
#media (min-width: 320px) {
.container {
padding: 0px 15px; }
.site-header .container {
padding: 0px; }
.slider-menu div {
padding: 50px 0px 24px 0px; }
.slider-menu p {
font-size: 12px; }
body {
margin: 0 0 65px;
/* bottom = footer height */ }
.site-footer {
height: 65px;
padding: 0px 10px; }
.site-footer p.pull-left {
display: none; }
.site-footer p.pull-right {
float: left !important; }
.list-image > div {
margin-top: 15px; }
.container > .navbar-collapse {
margin-left: 0px;
margin-right: 0px; }
.navbar-nav > li > p > a {
color: #fff; }
.navbar-nav {
margin: 0px auto;
width: 100%; }
.navbar-nav li {
width: 100%; }
.navbar-nav .container {
margin-left: 0px;
margin-right: 0px; }
.site-header .container > .navbar-header {
margin-left: auto;
margin-right: auto; } }
http://codepen.io/anon/pen/eNjQmO

Skew element horizontally but just right side

i want to have design as exactly below by help of HTML 5 and CSS 3. Here is jsfiddle how i do it.
Here is the example codes
<div class="header">Akşam Sizin İçin Önerdiklerimiz
<div class="skew"></div>
</div>
<div class="line"></div>
.header {
color: white;
font-size: 14px;
display: inline-block;
padding: 5px 10px;
background-color: #6b6a69;
position: relative;
}
.skew {
position: absolute;
-moz-transform: skewX(45deg);
-ms-transform: skewX(45deg);
-o-transform: skewX(45deg);
-webkit-transform: skewX(45deg);
transform: skewX(45deg);
right: -14px;
display: inline-block;
width: 40px;
height: 30px;
top: 0;
background: inherit;
z-index: -1;
}
.line {
height: 11px;
background-color: #6b6a69;
margin-top: -7px;
}
As you have seen that i used 3 html element to build this. What i want to achieve is to give a gradient background-color for whole that design. But there are 3 different elements so i can only apply gradient for each element separately and that wouldn't look as i want.
So i am trying to achieve that design by only 1 element via CSS 3 features like transformations.
At least skewing only right side as in the picture via removing div.skew element would be an improvement for me.
If it is possible to do that so how can i do that ?
Edit: Here is example how it looks when i apply gradient so that is why i want to simply remove extra elements for applying gradient to whole design.
This would be an easier way to do it: http://codepen.io/pageaffairs/pen/aDoFc
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
.header {
color: white;
font-size: 14px;
padding: 0 0 20px 0;
background-color: #6b6a69;
position: relative;
background: -moz-linear-gradient(left, rgba(30,87,153,1) 0%, rgba(180,187,193,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(30,87,153,1)), color-stop(100%,rgba(180,187,193,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, rgba(30,87,153,1) 0%,rgba(180,187,193,1) 100%);
background: -o-linear-gradient(left, rgba(30,87,153,1) 0%,rgba(180,187,193,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, rgba(30,87,153,1) 0%,rgba(180,187,193,1) 100%); /* IE10+ */
background: linear-gradient(to right, rgba(30,87,153,1) 0%,rgba(180,187,193,1) 100%); /* W3C */
overflow: hidden;
}
span {position: relative; display: inline-block; padding: 5px 10px 0 10px;}
span:after {
content: " ";
width: 2000px;
height: 0;
position: absolute;
border-top: 20px solid white;
border-right: 0 solid transparent;
border-bottom: 0 solid transparent;
border-left: 20px solid transparent;
left: 100%;
top: 0;
}
</style>
</head>
<body>
<div class="header">
<span>Akşam Sizin İçin Önerdiklerimiz</span>
</div>
</body>
</html>

Unwanted space on left side of div

There is an unwanted gap between the left side of my div and the actual content inside of it (text, images). I have margin and padding both set to 0px for the class. The div is also right next to my nav bar, which may be somehow affecting the spacing.
body
{
background-color: #f5f5f7;
background-image: url("../img/powder.png");
background-repeat: no-repeat;
background-attachment: fixed;
background-position: right bottom;
font-family: 'Lora', serif;
padding: 0px;
}
.main /* the extra space is occuring in this class */
{
position: relative;
left: 200px;
width: 800px;
height: 400px;
text-align: left;
border-radius: 10px;
padding-left: 0px;
margin: 0px;
background-color: rgba(207, 207, 207, 0.5);
}
nav ul
{
background: #efefef;
background: linear-gradient(to right, #d3c965 0%, #89822a 100%);
background: -moz-linear-gradient(left, #d3c965 0%, #89822a 100%);
background: -webkit-linear-gradient(left, #d3c965 0%,#89822a 100%);
background: -o-linear-gradient(left, #d3c965 0%, #89822a 100%);
box-shadow: 0px 0px 9px rgba(0,0,0,0.15);
padding: 0px 20px;
border-radius: 10px;
list-style: none;
/* display: inline-table;*/
margin: 0px;
}
nav ul li:hover
{
background: linear-gradient(to right, #993300, #4C1A00); /*Standard syntax */
background: -moz-linear-gradient(left, #993300, #4C1A00);/* For Firefox 3.6 to 15 */
background: -webkit-linear-gradient(left, #993300, #4C1A00);/* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(left, #993300, #4C1A00); /* For Opera 11.1 to 12.0 */
}
nav ul li:hover a
{
color: #fff;
}
nav ul li a
{
display: block;
padding: 25px 40px;
color: #4C4C4C;
text-decoration: none;
margin: 0px;
}
The live version of this is available at msu.edu/~bridsonc/henna
Make the div float like the menu.
.main {
float: left
/* change left:200px to margin-left:20px */
Maybe you could than add a padding-left of 10px
change the position of the div from relative to fixed:
.main /* the extra space is occuring in this class */
{
position: fixed;