CSS skew angle align with 3 rows - html

See attached image below. I want to preserve it with pure CSS. That means I'm only looking for a CSS only solution.
Using this CSS code I can get middle row (look at the image) as I needed. But not for top and bottom rows. Problem is skew angle is not align like image.
.slider-single {
position: relative;
background: #f5f5f5;
padding-top: 70px;
padding-bottom: 70px;
}
.slider-single::before {
content: "";
position: absolute;
background: #0072c6;
width: 100%;
height: 100%;
right: 0;
top: 0;
transform: skewX(-16deg) translateX(-50%);
z-index: -1;
}
.skew-bar-top {
position: absolute;
height: 40px;
background: red;
width: 100%;
top: 0;
left: 0;
}
.skew-bar-top::before {
content: '';
position: absolute;
width: 100%;
height: 100%;
background: #21255d;
transform: skewX(-16deg) translateX(-50%);
}
<div class="slider">
<div class="slider-single with-bg img">
<div class="skew-bar-top"></div>
<div class="container">
<div class="row align-items-center">
<div class="col-md-6 col-lg-6">
-- contents
</div>
<div class="col-md-6 col-lg-6">
-- contents
</div>
</div>
</div>
<div class="skew-bar-bottom"></div>
</div>
</div>

You don't need 3 rows, you can keep only one and play with backgrounds
.container {
height: 400px;
border: solid #0000;
border-width: 50px 0; /* control the width of the top/bottom border */
background:
/* the middle gradient */
linear-gradient(110deg, blue 50%,red 50.1%) padding-box,
/* the border gradient*/
linear-gradient(110deg,red 50%,yellow 50.1%) border-box;
background-origin: border-box;
background-clip: padding-box,border-box;
}
<div class="container">
</div>
Also like below for different coloration on each border:
.container {
height: 300px;
border-top: 50px solid #0000;
padding-bottom: 60px;
background:
/* the middle gradient */
linear-gradient(110deg,purple 50%,green 50.1%),
/* the top gradient */
linear-gradient(110deg,blue 50%,red 50.1%),
/* the bottom gradient*/
linear-gradient(110deg,red 50%,yellow 50.1%);
background-origin: border-box;
background-clip: content-box,padding-box,border-box;
}
<div class="container">
</div>

I made this code with looking though This website.
Now, it enables you to scale the size. However, I can not just let the middle part be bigger because it is hard to calculate the position of the angle.
Here is the code:
<title>测试</title>
<style type="text/css">
.RightAngleTrapezoid {
width:120px;height:0;margin:100px auto;
border-right:15px solid transparent;
border-top:15px solid;
position:absolute;
}
</style>
<button onclick="ChangeSize()">
Test To change size
</button>
<input id="time" value="3">
<div id="Flag" style="transform:scale(0.5,1.1)">
<div id="UpPosition">
<div class="RightAngleTrapezoid" style="color:red;transform:rotate(360deg);left:0;top:0;width:250"></div>
<div class="RightAngleTrapezoid" style="color:yellow;transform:rotate(180deg);left:250;top:0;width:180;"></div>
</div>
<div id="MiddlePosition">
<div class="RightAngleTrapezoid" style="color:blue;transform:rotate(360deg);left:0;top:15;width:170;border-right:80px solid transparent;border-top:90px solid"></div>
<div class="RightAngleTrapezoid" style="color:red;transform:rotate(180deg);left:170;top:15;width:195;border-right:80px solid transparent;border-top:90px solid"></div>
</div>
<div id="DownPosition">
<div class="RightAngleTrapezoid" style="color:red;transform:rotate(360deg);left:0;top:105;width:155"></div>
<div class="RightAngleTrapezoid" style="color:yellow;transform:rotate(180deg);left:155;top:105;width:275;"></div>
</div>
</div>
<script>
function ChangeSize(){
var element = document.getElementById("Flag");
var ho = 0.5;
var ve = 1.1;
var times = document.getElementById("time").value;
console.log(element);
element.setAttribute("style", "transform:scale("+ho * times + ","+ve * times + ");");
}
</script>
Tips: You can put the code into an IDE because I do not know why it won't work with StackOverflow's test and you can test Here online.
This is the screenshot of the result(As you want):

Related

How to opacify only the background outline?

I want to opacify just the outline of the background, that small part between the yellow container and the end of the VP. Could you please help me? Thank you.
HTML
`e
.menu-jumbotron {
background: #160b00;
background-image: url("/Users/Desktop/PROJECTS/STELLINA 2/images/food-img.jpg");
background-size: cover;
max-width: 100%;
}
.jumbotron-form {
background: #160b00 !important;
}
.border {
width: 100%;
height: 40.58rem;
border: 2px solid #fed675 !important;
}
.opacity-bg {
width: 65%;
height: 100%;
background: rgba(22, 11, 0, 0.9);
}
<section class="welcome-section">
<div class="jumbotron menu-jumbotron jumbotron-fluid">
<div class="container menu-container">
<div class="border">
<div class="opacity-bg">
<div class="headers">
<h3 class="inner-text small">vieni a trovarci</h3>
<h1 class="header display-4">Etoile Food Bar & Cocktails</h1>
</div>
<div class="phone-number-outer">
<div class="phone-number-inner">
<p>123-456789</p>
</div>
</div>
<div class="menu-button">
<button type="button" class="menu-btn btn btn-primary button-wrapper">Scopri il nostro menu</button>
</div>
</div>
</div>
</div>
</div>
</section>
Background that I want to opacify`
Is this what you try to achieve?
.menu-jumbotron {
background-color: #c7731f;
background-image: url('https://via.placeholder.com/1000x1000.jpg');
background-size: cover;
max-width: 100%;
}
.jumbotron-form {
background: #160b00 !important;
}
.border {
display: flex;
width: 100%;
height: 40.58rem;
border: 2px solid #fed675 !important;
}
.opacity-bg {
width: 65%;
height: 100%;
background: rgba(22, 11, 0, 0.5);
}
<section class="welcome-section">
<div class="jumbotron menu-jumbotron jumbotron-fluid">
<div class="container menu-container">
<div class="border">
<div class="opacity-bg">
<div class="headers">
<h3 class="inner-text small">vieni a trovarci</h3>
<h1 class="header display-4">Etoile Food Bar & Cocktails</h1>
</div>
<div class="phone-number-outer">
<div class="phone-number-inner">
<p>123-456789</p>
</div>
</div>
<div class="menu-button">
<button type="button" class="menu-btn btn btn-primary button-wrapper">Scopri il nostro menu</button>
</div>
</div>
</div>
</div>
</div>
</section>
This was an interesting problem to tackle. I came up with two possible ideas: one is somewhat complex but uses true opacity, and the other is simpler but uses a trick to fake opacity.
True Opacity Solution
The idea is to use two background images. The first one will have opacity applied to it, and the other will not. Two images are required since, to my knowledge, you can't apply opacity to just part of the image.
* {
margin: 0;
}
section.welcome {
--padding: 3em;
--border-width: 0.25em;
position: relative;
padding: var(--padding);
}
.bg {
position: absolute;
background-image: url('https://wallpapercave.com/wp/1OXITrf.jpg');
background-size: cover;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: -1;
}
section.welcome > .bg {
opacity: 0.25;
}
.inner {
position: relative;
border: var(--border-width) solid red;
overflow: hidden;
}
.inner .bg {
background-position: calc(var(--padding) * -1 - var(--border-width)) calc(var(--padding) * -1 - var(--border-width));
width: calc(100% + 2 * var(--padding) + 2 * var(--border-width));
}
.content {
color: #fff;
background: rgba(0, 0, 0, 0.75);
min-height: 10em;
width: 65%;
}
<section class="welcome">
<div class="bg"></div>
<div class="inner">
<div class="bg"></div>
<div class="content">
<p>Hello world</p>
</div>
</div>
</section>
The trickiest bit is getting the images to align. Since there are two background images at play, in order for the effect to look cohesive, background-position must be carefully calculated so it aligns with the opacity-ified image.
The key line, which moves the inner image backwards by an amount equal to the welcome sections padding and the content's border width:
background-position: calc(var(--padding) * -1 - var(--border-width)) calc(var(--padding) * -1 - var(--border-width));
Using Shadow to Fake Opacity
Opacity is used to allow part of the background to show through. If you know that the background is white or some other color, then you can fake opacity by using box-shadow. This solution is simpler since it only requires one background image now, but you still want to calculate the size of the shadow for best effect.
* {
margin: 0;
}
section.welcome {
--padding: 3em;
--border-width: 0.25em;
position: relative;
padding: var(--padding);
background-image: url('https://wallpapercave.com/wp/1OXITrf.jpg');
background-size: cover;
}
.inner {
border: var(--border-width) solid red;
box-shadow: 0 0 0 calc(var(--border-width) + var(--padding)) rgba(255, 255, 255, 0.75);
}
.content {
color: #fff;
background: rgba(0, 0, 0, 0.75);
min-height: 10em;
width: 65%;
}
<section class="welcome">
<div class="inner">
<div class="content">
<p>Hello Woorld</p>
</div>
</div>
</section>

Is it possible to create Multiple CSS3 using Transform or gradient Background?

I want to achieve this kind of Layout using Css Transform or gradient Background?(see image below). Right now im stuck with it using conic-gradient, i dont know how to put a gradient background on it.
see snippet below. run the code snippet as fullpage.
Thanks Guys.
//gol-bg
.my-bg-image {
background: url("https://via.placeholder.com/728x90.png?text=Background-image+Backgground-image+Background-image") 0 0 / cover no-repeat;
}
.gol-bg {
display: block;
height: 200px;
width: 700px;
position: relative;
background: conic-gradient(
transparent 136deg, transparent 0 140deg, yellow 140deg);
.my-content {
position: relative;
z-index: 1;
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="bg-dark my-bg-image">
<div class="row no-gutters">
<div class="col-6">
<div class="gol-bg">
<div class="my-content">content</div>
</div>
</div>
</div>
</div>
I'm not sure if i understood your question correctly but
Yes, you can use multiple transforms
(Also, take a look at this:
https://bennettfeely.com/clippy/)
Here's an example:
div {
height: 100px;
width: 100px;
background: #000;
color: #fff;
margin: 5em auto; /* Just to center it a bit */
/* Transform part */
transform: scale(2) rotate(90deg);
}
<div>Hello World</div>
this may not be the answer you are looking for but you can do this too. CSS is capable of making all sorts of shapes.
.my-bg-image {
background: url("https://via.placeholder.com/728x90.png?text=Background-image+Backgground-image+Background-image") 0 0 / cover no-repeat;
}
.gol-bg {
display: block;
position: relative;
width: 250px;
height: 0px;
border-left: 50px solid red;
border-right: 50px solid red;
border-bottom: 100px solid red;
border-top: 100px solid red;
position: relative;
}
.gol-bg:after {
content: '';
position: absolute;
background: transparent linear-gradient(91deg, #02b3bc 0, #171c8f 100%) 0 0 no-repeat padding-box;
width: 0;
height: 0;
border-left: 250px solid transparent;
border-right: 100px solid transparent;
border-bottom: 100px solid red;
position: absolute;
content: "";
top: 0px;
left: -50px;
}
.gol-bg .my-content {
position: relative;
z-index: 1;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="bg-dark my-bg-image">
<div class="row no-gutters">
<div class="col-6">
<div class="gol-bg">
<div class="my-content">content</div>
</div>
</div>
</div>
</div>

Bootstrap 4 stretch background of column to fill width of screen without container-fluid and keep alignment with grid [duplicate]

It's a little bit hard to explain, that's why i also can't find the answer on Google.
I'm working with Bootstrap 3, and i need a full width background image. On top of that 2 transparent color backgrounds. I made a example image to make it all clear:
1+2: combined transparent color background
3+4: combined transparent color background
1+2+3+4: combined background image (lowest layer)
Does anyone know if this is possible and how? Thanks for your help!
Yes, using the techniques outlined in this question but extending it to the columns.
The Codepen Demo (below) shows the result better than the Stack Snippet which is included for reference.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
overflow: hidden;
/* prevent scrollbar */
}
.container {
width:50%;
margin:auto;
margin-top: 1em;
position: relative;
overflow: visible;
}
.extra:before {
content: '';
display: block;
/* override bootstrap */
position: absolute;
top: 0;
left: 50%;
width: 100vw;
height: 100%;
transform: translate(-50%, 0);
}
[class*="col"] {
border: 2px solid grey;
min-height: 120px;
position: relative;
}
.left:before {
content: '';
position: absolute;
height: 100%;
width: 100vw;
top: 0;
right: 0;
background: rgba(255, 0, 0, 0.5)
}
.right:before {
content: '';
position: absolute;
height: 100%;
width: 100vw;
top: 0;
left: 0;
background: rgba(0, 0, 255, 0.25);
}
<div class="container extra">
<div class="row">
<div class="col-sm-4 left"></div>
<div class="col-sm-8 right"></div>
</div>
</div>
Codepen Demo
I think i figured it out.. Thanks to Paulie_D
Very simple example:
HTML:
<div class="fullwidth">
<div class="cell red20">xxx</div>
<div class="container cell">
<div class="row">
<div class="col-sm-4 red20">xx</div>
<div class="col-sm-8 red50">xx</div>
</div>
</div>
<div class="cell red50">xxx</div>
</div>
CSS:
.fullwidth {
background: url('http://www.ustudy.eu/nl/wp-content/uploads/2013/10/Test-taking-from-Flickr.jpg');
display:table;
width:100%;
}
.cell{
display:table-cell;
vertical-align:top;
}
.red20{
background-color:rgba(255,0,0,0.2);
}
.red50{
background-color:rgba(255,0,0,0.5);
}
Link to jsfiddle: https://jsfiddle.net/DTcHh/14045/

Positioning points along a line

I'm trying to build the following component with CSS, but I can't get the first and last point to sit flush against the ends of the line.
It must be able to support an arbitrary number of points (between 1 and 4) and I can't rely on flexbox being there either.
I have a React component that's generating HTML that looks like this:
<div class="row">
<div class="col first" style="width:33%">
<div class="marker complete"></div>
<label>Feedback</label>
</div>
<div class="col" style="width:33%">
<div class="marker partial"></div>
<label>Observation</label>
</div>
<div class="col last" style="width:33%">
<div class="marker review"></div>
<label>Documentation</label>
</div>
</div>
The JavaScript calculates the column sizes before rendering and in my codepen implementation, I'm just centering all the content in each column.
I can sort of hack a solution by using the first and last classes to relatively position the end items, but invariably when the screen size changes, I start to get the edges of the line poking out from behind the points.
Does anyone know of a more sensible layout to start building this with?
My idea would be to set row as display: table-row, and then use a pseudo element to generate the horizontal bar. However, you run into the issue that you cannot know with CSS and HTML alone what the position of the first and last circle is relative to the size of the container. Therefore, it is not possible to use a full width item.
Another approach is using the labels as root items for the pseudo elements. They are always the full width of the column, so they give a nice indication what needs to be used.
The following proposed solution should work with IE9. The only special thing that is used is calc and after. (Instead of calc you can also use a transform: translate if you want.)
The basic idea is to use a table row, which would automatically scale nicely, and then use the labels as roots on which you can build the progress bar.
label:after {
content: "";
height: .5em;
background: #e2e2e2;
width: 100%;
position: absolute;
top: calc((100% - 1.5em) / 2); /* -1 to compensate text, -.5 for height bar */
left: 0;
z-index: -1;
}
.first label:after, .last label:after {
width: 50%;
}
.first label:after {
left: auto;
right: 0;
}
.single label:after {content: none;}
Here ya go. I assume this is what you are looking for.
<div class="row">
<div class="col" style="width:33%">
<div class="marker marker1 complete"></div>
<label>Feedback</label>
</div>
<div class="col2" style="width:33%">
<div class="marker marker2 partial"></div>
<label>Observation</label>
</div>
<div class="col3" style="width:33%">
<div class="marker marker3 review"></div>
<label>Documentation</label>
</div>
</div>
https://jsfiddle.net/norcaljohnny/e6nm2rbv/
*if JS was/is allowed I can put some conditions in it based on number and word length and adjust marker indentions.
Basically I used display blocks, margins and secondary marker classes for each block.
.row {
display: table;
margin: 0 auto;
position: relative;
width: 100%;
}
.col {
display: table-cell;
width: 33%;
text-align: center;
}
.marker {
width: 30px;
height: 30px;
background-color: lightgray;
border-radius: 30px;
margin: 0 auto;
}
.complete {
background-color: blue;
}
.partial {
background-color: blue;
box-sizing: border-box;
border: 8px solid lightgray;
}
.review {
background-color: lightblue;
}
.col:not(:last-child) > .marker:after {
content: '';
display: inline-block;
width: 67%;
height: 0;
border: 3px solid lightgray;
position: absolute;
left: 16.5%;
top: 12.5px;
z-index: -10;
}
/* ------------------------------------------- */
.wrapper {
display: flex;
align-items: center;
justify-content: center;
padding: 0 100px;
}
.point {
height: 30px;
background-color: lightgray;
border-radius: 30px;
flex: 0 0 30px;
position: relative;
}
.line {
height: 0;
border: 3px solid lightgray;
flex: 1 0;
}
.blue {
background-color: blue;
}
.lightblue {
background-color: lightblue;
}
.border {
background-color: lightgray;
background-image: radial-gradient(at center center, blue 0, blue 8px, transparent 8px, transparent 100%);
}
.point label {
position: absolute;
left: -50%;
top: 100%;
text-align: center;
}
<h1>Non flex</h1>
<div class="row">
<div class="col first">
<div class="marker complete"></div>
<label>Feedback</label>
</div>
<div class="col">
<div class="marker partial"></div>
<label>Observation</label>
</div>
<div class="col last">
<div class="marker review"></div>
<label>Documentation</label>
</div>
</div>
<h1>Flex</h1>
<div class="wrapper">
<div class="point blue">
<label>Feedback</label>
</div>
<div class="line"></div>
<div class="point blue border">
<label>Observation</label>
</div>
<div class="line"></div>
<div class="point lightblue">
<label>Documentation</label>
</div>
</div>

Bootstrap full-width with 2 different backgrounds (and 2 columns)

It's a little bit hard to explain, that's why i also can't find the answer on Google.
I'm working with Bootstrap 3, and i need a full width background image. On top of that 2 transparent color backgrounds. I made a example image to make it all clear:
1+2: combined transparent color background
3+4: combined transparent color background
1+2+3+4: combined background image (lowest layer)
Does anyone know if this is possible and how? Thanks for your help!
Yes, using the techniques outlined in this question but extending it to the columns.
The Codepen Demo (below) shows the result better than the Stack Snippet which is included for reference.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
overflow: hidden;
/* prevent scrollbar */
}
.container {
width:50%;
margin:auto;
margin-top: 1em;
position: relative;
overflow: visible;
}
.extra:before {
content: '';
display: block;
/* override bootstrap */
position: absolute;
top: 0;
left: 50%;
width: 100vw;
height: 100%;
transform: translate(-50%, 0);
}
[class*="col"] {
border: 2px solid grey;
min-height: 120px;
position: relative;
}
.left:before {
content: '';
position: absolute;
height: 100%;
width: 100vw;
top: 0;
right: 0;
background: rgba(255, 0, 0, 0.5)
}
.right:before {
content: '';
position: absolute;
height: 100%;
width: 100vw;
top: 0;
left: 0;
background: rgba(0, 0, 255, 0.25);
}
<div class="container extra">
<div class="row">
<div class="col-sm-4 left"></div>
<div class="col-sm-8 right"></div>
</div>
</div>
Codepen Demo
I think i figured it out.. Thanks to Paulie_D
Very simple example:
HTML:
<div class="fullwidth">
<div class="cell red20">xxx</div>
<div class="container cell">
<div class="row">
<div class="col-sm-4 red20">xx</div>
<div class="col-sm-8 red50">xx</div>
</div>
</div>
<div class="cell red50">xxx</div>
</div>
CSS:
.fullwidth {
background: url('http://www.ustudy.eu/nl/wp-content/uploads/2013/10/Test-taking-from-Flickr.jpg');
display:table;
width:100%;
}
.cell{
display:table-cell;
vertical-align:top;
}
.red20{
background-color:rgba(255,0,0,0.2);
}
.red50{
background-color:rgba(255,0,0,0.5);
}
Link to jsfiddle: https://jsfiddle.net/DTcHh/14045/