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>
Related
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):
I am trying to make some CSS code so that I can have vertical zigzag lines on the left and right of my BODY tag.
I want it to look like a ticket... something like this going from top to the bottom of the page on the left and right: https://roalddahl.fandom.com/wiki/Golden_Ticket?file=Golden_Ticket.png
I found this question with the requirement of the zigzags on the left, but it's not working correctly for me when I use on on the BODY: zigzag border in css left side
body {
background-color: #c5ac5a;
background: linear-gradient(-137deg, #c5ac5a 6px, transparent 0) 0 5px, linear-gradient(320deg, #c5ac5a 5px, #fff 0) 0 5px;
background-position: left;
background-repeat: repeat-y;
background-size:10px 10px;
}
<body>
<h1>The Title</h1>
</body>
EDIT: I want the whole background to be #c5ac5a and the vertical zigzags on both sides.
Use the :before and :after to achieve your goal. (I also changed the columns to use flex, but that's not necessary for the issue at hand). See provided snippet below:
body {
background: white;
}
.ticket {
background-color: #c5ac5a;
position: relative;
padding: 10px;
}
.ticket:before,
.ticket:after {
top: 0;
left: -10px;
content: '';
width: 10px;
height: 100%;
position: absolute;
background-color: #c5ac5a;
background: linear-gradient(-137deg, #c5ac5a 6px, transparent 0) 0 5px, linear-gradient(320deg, #c5ac5a 5px, transparent 0) 0 5px;
background-position: left;
background-repeat: repeat-y;
background-size:10px 10px;
}
.ticket:after {
left: auto;
right: -10px;
top: 0;
transform: scaleX(-1);
}
.hr {
border-bottom: 2px solid black;
}
h1 {
text-align: center;
font-family: Times, serif;
font-size:40px;
}
.column {
text-align:center;
flex: 1 1 auto;
padding: 10px 0;
}
.row {
display: flex;
}
.ticket__footer {
font-size: 12px;
text-align: center;
padding-top: 10px;
}
.bold {
font-weight:bold;
}
<div class="ticket">
<div class="hr">
</div>
<div class="title">
<h1>
GOLDEN TICKET
</h1>
</div>
<div class="hr">
</div>
<div class="row">
<div class="column">
<span class="small">DATE</span></br>
<span class="bold">FEB. 1</span>
</div>
<div class="column">
<span class="small">TIME</span></br>
<span class="bold">10 A.M (SHARP)</span>
</div>
<div class="column">
<span class="small">PLACE</span></br>
<span class="bold">RIGHT HERE</span>
</div>
</div>
<div class="hr">
</div>
<div class="ticket__footer">
THIS GOLDEN TICKET ENSURES ADMITTANCE
</div>
</div>
I need some help, I need to code this image:
This is what I have so far:
I tried adding a margin-top, padding-top, tried all combinations of position relative and absolute, I just need some ideias on how to do it.
This is how my code is structured:
<div class="background-oficina">
<div class="container">
<div class="col-xs-12 text-center">
<img class="logo" src="logo.png" alt="Oficina de Redação">
</div>
</div>
</div>
This is the css for the two classes that I'm using:
.background-oficina {
background: #fff url("bg-texture.png");
}
.logo {
padding-top: 50px;
margin: 0 auto;
}
You could use an additional absolutely positioned element to which you assign the repeated background pattern and which you put behind the original element by using z-index: -1:
html, body {
margin: 0;
}
.background-oficina {
position: relative;
border: 1px solid #333;
border-bottom: none;
}
.bg-container {
position: absolute;
z-index: -1;
left: 0;
top;
width: 100%;
height: 120px; /* or whatever height is desired */
background: url("http://placehold.it/20x15/cff");
}
.text-center {
text-align: center;
}
.logo {
padding-top: 50px;
margin: 0 auto;
}
<div class="background-oficina">
<div class="bg-container"></div>
<div class="container">
<div class="col-xs-12 text-center">
<img class="logo" src="http://placehold.it/200x150/fb7" alt="Oficina de Redação">
</div>
</div>
</div>
Your trying this, you can set default height and width to parent div that consist of that logo then using position:absolute you can push that out of parent div, but don't add overflow:hidden to parent div or else it hides your image or element that you are trying to push outside parent div as hidden.
.background-oficina {
background: #fff url("https://via.placeholder.com/800x100/000") no-repeat;
box-shadow: inset 0 0 0 1000px rgba(255, 255, 255, 0.2);
background-size: 100% 100%;
width: 100%;
height: 100px;
position: relative; /*Add this*/
}
.logo {
padding-top: 50px;
margin: 0px auto;
position: absolute; /*Add this*/
bottom: -20px; /*Add this*/
}
<div class="background-oficina padding margin-bottom">
<div class="container">
<div class="col-xs-12 text-center margin-bottom">
<img class="logo" src="https://via.placeholder.com/50/ff2" alt="Oficina de Redação">
</div>
</div>
</div>
I'm trying to create a text block with transparent background which is the same width as the image. However if I just add padding to the header then some may overlap or not be long enough due to the varying length in text.
Currently looks like this: http://puu.sh/sdBCX/994cc31da8.png
Here is the relevant HTML:
<div class="container-fluid">
<div class="row">
<div class="artist-grid">
<div class="col-lg-2"></div>
<div class="col-lg-2">
<img id="#artistTile" src="https://dummyimage.com/300x300">
<h3><span>BASSNECTAR</span></h3>
</div>
<div class="col-lg-2">
<img id="#artistTile" src="https://dummyimage.com/300x300">
<h3><span>DATSIK</span></h3>
</div>
<div class="col-lg-2">
<img id="#artistTile" src="https://dummyimage.com/300x300">
<h3><span>CHAINSMOKERS</span></h3>
</div>
<div class="col-lg-2">
<img id="#artistTile" src="https://dummyimage.com/300x300">
<h3><span>ZEDS DEAD</span></h3>
</div>
<div class="col-lg-2"></div>
</div>
</div>
</div>
And the relevant CSS:
h3 {
position: absolute;
top: 244px;
width: 100%
}
h3 span {
color: white;
background: rgb(0, 0, 0);
background: rgba(0, 0, 0, 0.7);
padding: 10px;
}
.artist-grid {
padding-top: 22px;
}
#artistTile {
position: relative;
max-width: 100%;
}
Cheers!
div {
width: 200px;
height: 200px;
display: block;
position: relative;
}
div::after {
content: "";
background: url(image.jpg);
opacity: 0.5;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
z-index: -1;
}
I'm trying to make div that overlays background image, but not content, like this:
<div class="container-fluid">
<div class="row">
<div class="col-sm-12 featured">
<div class="overlay"></div> <!--optional-->
<center>
<img src="img/logo.svg">
<h1>Title</h1>
</center>
</div>
</div>
</div>
Where div featured has background image:
.featured {
background-image: url(img/bg.jpg);
}
Now I've tried:
.overlay {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: rgba(255, 255, 255, 0.4);
}
And also:
.featured:before {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: rgba(255, 255, 255, 0.4);
}
But it all makes overlay above content. Any better techniques?
<div style="background: #f6f2ea url(images/file.jpg) no-repeat center center;
min-height: 50%; background-size:cover;">
<div id="overlay-black">
<div>
<h3 class="bg-color">TEXT</h3>
</div>
</div>
</div>
and the css for overlay-black
#overlay-black {
background:rgba(50, 50, 50, 0.2);
opacity:0;
-webkit-transition: opacity .25s ease;
opacity:100;
height: 100%;
width: 100%;
}
I was able to do it just by declaring a position and z-index on the <h1> and img elements
See my fiddle here: https://jsfiddle.net/LwwgLc0w/