Remove lines from image background - html

I'm not the best in css, but when I have a div with a background image, and I overlay a svg that only has a border, the border lines are shown on some devices. It should look like this.
But when I load this on mobile view, the border lines are shown. How can i fix this?
I've tried to add a padding, and tried to use an backgroud position offset, but that didn't work.
* {
box-sizing: border-box;
margin: 0;
padding: 0;
background-origin: content-box;
}
body {
margin: 0;
font-family: Ubuntu;
overflow: hidden;
/* Hide scrollbars */
}
.container {
margin: auto;
}
.column.left {
margin: 0;
float: left;
}
.column.right {
float: right;
}
/* Clear floats after the columns */
.item {
display: block;
overflow: hidden;
position: relative;
background-size: cover;
background-position: left top;
background-origin: content-box;
background-repeat: no-repeat;
/*border-radius: .9rem .9rem 0 .9rem;*/
}
.item h2 {
font-family: Ubuntu, sans-serif;
text-shadow: 0 0 3px rgba(0, 0, 0, .8);
background: -webkit-linear-gradient(top, transparent 0%, #000000);
background: linear-gradient(180deg, transparent 0%, #000000);
bottom: 0;
color: #fff;
font-weight: normal;
left: 0;
margin: 0;
position: absolute;
right: 0;
}
.item1 img,
.item2 img,
.item3 img {
width: 100%;
height: auto;
}
<div class="container">
<div class="content">
<div class="overzicht">
<div class="column left">
<div class="item item1" style="background-image: url('https://i.regiogroei.cloud/552x310/43692b31-6c5e-3c1c-9734-0fda6b587107.jpg'); background-size: cover; background-position: center">
<img src="./StoreplayNEWS_Tekengebied 1.svg" style="position: absolute; z-index: 5; width: 100%; height:100%" alt="">
<h2 class="title">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin tincidunt sed justo sit amet rhoncus</h2>
</div>
</div>
<div class="column right">
<div class="item item2" style="background-image: url('https://i.regiogroei.cloud/552x310/13650346-f88e-3b81-b54a-af81dccd4369.jpg'); background-size: cover; background-position: center">
<img src="./StoreplayNEWS_Tekengebied 1.svg" style="position: absolute; z-index: 5; width: 100%; height:100%" alt="">
<h2 class="title">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin tincidunt sed justo sit amet rhoncus</h2>
</div>
<div class="item item3" style="background-image: url('https://i.regiogroei.cloud/552x310/ee982215-e923-3ea5-b65f-2230e1d36fad.jpg'); background-size: cover; background-position: center">
<img src="./StoreplayNEWS_Tekengebied 1.svg" style="position: absolute; z-index: 5; width: 100%; height:100%" alt="">
<h2 class="title">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin tincidunt sed justo sit amet rhoncus</h2>
</div>
</div>
</div>
</div>
</div>
Thanks in advance!

I've found the answer. The problem was that the .item h2's background was overlapping. I've changed that to this and that fixed the problem.
.item h2 {
font-family: Ubuntu, sans-serif;
text-shadow: 0 0 3px rgba(0, 0, 0, .8);
background: -webkit-linear-gradient(top, transparent 0%, #000000);
background: linear-gradient(180deg, transparent 0%, #000000);
bottom: 0;
color: #fff;
font-weight: normal;
left: 0;
margin: 1px;
position: absolute;
right: 0;
}

Try setting the border and outline property to zero on the parent and child elements.
{
border: none;
outline: none
}

Related

How to draw curved div stacked on top of one another?

I am working on web application using Rect JS and I only have beginners knowledge in HTML and CSS.So can you please suggest me to achieve something like the following with a responsive UI that containing button,text and image.How can I write css styles to curve a div and place another one below it without any blank space.
Can someone please suggest any solution? Any help would be really appreciated.I have tried radial-gradient method like following.
<div className="background1">
....
</div>
<div className="background2">
.....
</div>
.background1 {
width: 100%;
background: radial-gradient(120% 800px at 50% -30px, red 75%,
transparent 75%) no-repeat;
z-index: 2;
position:relative;
margin-bottom: 0px;
}
.background2 {
background-color: #202492;
width: 100%;
background: radial-gradient(120% 800px at 50% -30px,blue 75%,
transparent 75%) no-repeat;
position: relative;
z-index: 1;
margin-top: -50px;
}
But I am getting this
Blockquote
I think you need something like this:
.btn1 {
background: #190b0b;
color: #fff;
padding: 1em 2.5em;
box-shadow: 1px 2px 7px -1px #190b0b;
}
.background1 {
width: 100%;
background: red;
z-index: 2;
position: relative;
margin-bottom: 0px;
padding: 6em 0;
border-radius: 0 0 10em 10em;
text-align: center;
}
.background2 {
background-color: #202492;
z-index: 1;
position: relative;
margin-bottom: 0px;
padding: 6em 0;
border-radius: 0 0 10em 10em;
text-align: left;
width: 100%;
top: -10em;
color: #fff;
}
.background3 {
background-color: blue;
z-index: 0;
position: relative;
margin-bottom: 0px;
padding: 6em 0;
border-radius: 0 0 10em 10em;
text-align: left;
width: 100%;
top: -20em;
color: #fff;
}
.text {
margin-top: 6em;
max-width: 50%;
padding: 0 6em;
}
<div class="background1">
<button class="btn1">Button</button>
</div>
<div class="background2">
<div class="text">
<h2> Text1 </h2>
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse pellentesque, nibh sed tempus bibendum, lacus turpis dictum ipsum, nec consectetur diam nisi eget mauris. </p>
</div>
</div>
<div class="background3">
<div class="text">
<h2> Text2 </h2>
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse pellentesque, nibh sed tempus bibendum, lacus turpis dictum ipsum, nec consectetur diam nisi eget mauris. </p>
</div>
</div>
Just change in border-radius and padding values to have the perfect curve that you want.
You can use border-bottom-left-radius and border-bottom-lright-radius or border-radius: 0px 0px xxxpx xxpx;
div {
height: 300px;
width: 300px;
border-bottom-right-radius: 200px;
border-bottom-left-radius: 200px;
background: black;
}
<div></div>

How can I stack Columns when window is resized [duplicate]

This question already has answers here:
Flexbox responsive row column layout
(3 answers)
Converting desktop layout to single-column mobile layout
(1 answer)
Closed 1 year ago.
I am working on a website.
I have a container, that has two columns. On the left, I have a product image, that when you hover on it, it shows that product in use.
To the right, I have a title, description, tech drawings.
I want it so that when the screen is resized to a mobile format, or even if the browser is shrunk, the columns will stack on top of one another.
Right now the image just gets smaller and smaller until you cannot see it.
I tried several attempts at using FlexBox. Did not have any luck. Here was the guide/rules I was following: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
Here is a quick JSfiddle I made up to see what I am talking about. This does not have any "attempt" code in it. Just the base code for the containing div, left and right columns, with some example images and text. https://jsfiddle.net/fmcdLxa4/1/
.container {
max-width: 1200px;
margin: 0 auto;
display: flex;
padding: 15px;
}
/* Columns */
.left-column {
float: left;
width: 50%;
padding: 10px;
position: relative;
border-bottom: 1px solid #E1E8EE;
}
.right-column {
float: left;
width: 50%;
padding: 10px;
}
/* Left Column */
.left-column img {
display: block;
margin-left: auto;
margin-right: auto;
vertical-align: auto;
}
/* Right Column */
/* Product Description */
.product-description {
border-bottom: 1px solid #E1E8EE;
}
.product-description span {
font-size: 12px;
color: #358ED7;
letter-spacing: 1px;
text-transform: uppercase;
text-decoration: none;
}
.product-description h1 {
font-weight: 300;
font-size: 52px;
color: #43484D;
letter-spacing: -2px;
}
.product-description p {
font-size: 16px;
font-weight: 300;
color: #86939E;
line-height: 24px;
}
.product-description a {
color: #358ED7;
}
.flip-box {
background-color: transparent;
width: 100%;
height: 100%;
perspective: 1000px;
}
.flip-box-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 0.8s;
transform-style: preserve-3d;
}
.flip-box:hover .flip-box-inner {
transform: rotateY(180deg);
}
.flip-box-front,
.flip-box-back {
position: absolute;
width: 100%;
height: 100%;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.flip-box-front {
background-color: transparent;
}
.flip-box-back {
background-color: transparent;
transform: rotateY(180deg);
}
<div class="container">
<!-- Left Column -->
<div class="left-column">
<p> </p>
<div height="15"></div>
<div class="flip-box">
<div class="flip-box-inner">
<div class="flip-box-front">
<img src="https://dogtowndogtraining.com/wp-content/uploads/2012/06/300x300-061-e1340955308953.jpg" style="max-width: 100%">
</div>
<div class="flip-box-back">
<img src="http://www.deepdiveintel.com/wp-content/uploads/2013/09/Owl-Eye-art-300x300.jpg" style="max-width: 100%">
</div>
</div>
</div>
</div>
<!-- Right Column -->
<div class="right-column">
<!-- Product Description -->
<div class="product-description">
<span>Lorem ipsum dolor sit amet</span>
<h1>Lorem ipsum dolo</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi arcu sem, bibendum id tellus ac, aliquam faucibus massa. Nulla facilisi. Fusce vel condimentum velit. Praesent nec ultricies erat. Sed ante lectus, ultrices ut laoreet id, tincidunt
a augue.</p>
<p>Technical drawings: 7/0 | 8/0
<p />
</div>
</div>
</div>
Any help would be awesome!
flex can wrap if you set it so. Also, one of your card's image needs to remain in the flow, so it can size its container. then flex:1 1 XX% will do the job.
https://codepen.io/gc-nomade/pen/MWpxYZw
.container {
max-width: 1200px;
margin: 0 auto;
display: flex;
flex-wrap:wrap;
padding: 15px;
}
/* Columns */
.left-column {
flex:1 1 40%;
padding: 10px;
position: relative;
border-bottom: 1px solid #E1E8EE;
min-width:320px;
}
.right-column {
flex:1 1 40%;
padding: 10px;
}
/* Left Column */
.left-column img {
display: block;
margin-left: auto;
margin-right: auto;
vertical-align: auto;
}
/* Right Column */
/* Product Description */
.product-description {
border-bottom: 1px solid #E1E8EE;
}
.product-description span {
font-size: 12px;
color: #358ED7;
letter-spacing: 1px;
text-transform: uppercase;
text-decoration: none;
}
.product-description h1 {
font-weight: 300;
font-size: 52px;
color: #43484D;
letter-spacing: -2px;
}
.product-description p {
font-size: 16px;
font-weight: 300;
color: #86939E;
line-height: 24px;
}
.product-description a {
color: #358ED7;
}
.flip-box {
background-color: transparent;
width: 100%;
height: 100%;
perspective: 1000px;
}
.flip-box-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 0.8s;
transform-style: preserve-3d;
}
.flip-box:hover .flip-box-inner {
transform: rotateY(180deg);
}
.flip-box-back{
position: absolute;
top:0;
}
.flip-box-front,
.flip-box-back {
width: 100%;
height: 100%;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.flip-box-front {
background-color: transparent;
}
.flip-box-back {
background-color: transparent;
transform: rotateY(180deg);
}
<div class="container">
<!-- Left Column -->
<div class="left-column">
<p> </p>
<div height="15"></div>
<div class="flip-box">
<div class="flip-box-inner">
<div class="flip-box-front">
<img src="https://picsum.photos/id/1003/300/300" style="max-width: 100%">
</div>
<div class="flip-box-back">
<img src="https://picsum.photos/id/10/300/300" style="max-width: 100%">
</div>
</div>
</div>
</div>
<!-- Right Column -->
<div class="right-column">
<!-- Product Description -->
<div class="product-description">
<span>Lorem ipsum dolor sit amet</span>
<h1>Lorem ipsum dolo</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi arcu sem, bibendum id tellus ac, aliquam faucibus massa. Nulla facilisi. Fusce vel condimentum velit. Praesent nec ultricies erat. Sed ante lectus, ultrices ut laoreet id, tincidunt
a augue.</p>
<p>Technical drawings: 7/0 | 8/0
<p />
</div>
</div>
</div>

Change the colour of text that overlaps an image

The look I'm trying to achieve is if you have black text on a white page, but that text runs into an image. The section of text that is over the image changes it's colour.
I have a 'working' (not flexible) example here using a data attribute to grab the same text and set it on the :before element using content:
https://codepen.io/moy/pen/rNeaGbJ
/* General Shit */
body {
color: #000;
font-family: Arial;
font-size: 1.2rem;
line-height: 1.5;
}
h2 {
font-size: 3.6rem;
margin-bottom: 30px;
}
p {
margin-bottom: 30px;
}
.btn {
background: #000;
color: #fff;
display: inline-block;
font-size: 1.2rem;
padding: 15px 60px;
}
img {
width: 100%;
max-width: 100%;
}
/* Grid */
.grid {
clear: both;
margin: 0 auto;
padding: 30px 0;
max-width: 1000px;
}
.grid__item {
box-sizing: border-box;
float: left;
}
.grid--flip .grid__item {
float: right;
}
.grid__item--caption {
padding: 30px 60px;
}
.one-half {
width: 50%;
}
/* Title */
.title-wrap {
display: -webkit-box;
display: flex;
-webkit-box-pack: start;
justify-content: flex-start;
margin-left: -60%;
overflow: hidden;
position: relative;
}
.grid--flip .title-wrap {
-webkit-box-pack: end;
justify-content: flex-end;
margin-left: 0;
margin-right: -60%;
}
.title {
color: #000;
}
.grid--flip .title {
color: #fff;
}
.title:before {
color: #fff;
content: attr(data-title);
display: block;
overflow: hidden;
position: absolute;
width: 27.75%;
white-space: nowrap;
}
.grid--flip .title:before {
color: #000;
width: 34.75%;
}
<div class="grid">
<div class="grid__item grid__item--image one-half">
<img src="http://www.fillmurray.com/800/800" />
</div>
<div class="grid__item grid__item--caption one-half">
<div class="title-wrap">
<h2 class="title" data-title="Title goes here">Title goes here</h2>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
Shop Collection
</div>
</div>
<div class="grid grid--flip">
<div class="grid__item grid__item--image one-half">
<img src="http://www.fillmurray.com/800/800" />
</div>
<div class="grid__item grid__item--caption one-half">
<div class="title-wrap">
<h2 class="title" data-title="Title goes here">Title goes here</h2>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
Shop Collection
</div>
</div>
The problem with this is if...
I adjust the width of the container, all the values are off and it looks broken.
the title is longer and wraps onto multiple lines, it is cut off due to the overflow
And why the widths are what they are on the :before element (if someone could explain that'd be great ha)
So I tried a version using px values instead of % which fixes the issues of changing the container width. However I still have the issue of it not behaving right when text wraps onto 2 lines.
Example (using px): https://codepen.io/moy/pen/JjXoMvb
Can anyone think of a better solution for this? Am I overcomplicating this or missing something obvious?
Edit: PX example wrong incorrect, updated link now.
Use the CSS clip-path property
Example
:root {
--size: 100px;
}
.resizable {
border: 2px solid black;
width: calc(var(--size) * 3);
height: calc(var(--size) * 2);
resize: both;
overflow: auto;
}
.container {
position: relative;
}
.divider {
height: 100px;
}
.title {
position: absolute;
top: 0;
left: 0;
right: 0;
margin: 0;
}
img {
width: var(--size);
height: var(--size);
}
.left {
color: blue;
clip-path: polygon(0 0, var(--size) 0, var(--size) var(--size), 0 var(--size));
}
.right {
color: red;
clip-path: polygon(var(--size) 0, 100% 0, 100% 100%, 0 100%, 0 var(--size), var(--size) var(--size));
}
.container-reverse img {
float: right;
}
.container-reverse .left {
clip-path: polygon(100% 0, 100% var(--size), calc(100% - var(--size)) var(--size), calc(100% - var(--size)) 0);
}
.container-reverse .right {
clip-path: polygon(0 0, calc(100% - var(--size)) 0, calc(100% - var(--size)) var(--size), 100% var(--size), 100% 100%, 0 100%);
}
.container-reverse h1 {
text-align: right;
}
<div class="resizable">
<div class="container">
<h1 class="title left">Lorem ipsum dolor sit amet, consectetur adipiscing elit</h1>
<h1 class="title right">Lorem ipsum dolor sit amet, consectetur adipiscing elit</h1>
<img src="http://placehold.it/100x100" />
</div>
<div class="divider"></div>
<div class="container container-reverse">
<h1 class="title left">Lorem ipsum dolor sit amet, consectetur adipiscing elit</h1>
<h1 class="title right">Lorem ipsum dolor sit amet, consectetur adipiscing elit</h1>
<img src="http://placehold.it/100x100" />
</div>
</div>

Cutting Out a Shape using HTML and CSS

I'm trying to set up a banner which features an overlay with a cutout in it. Below the overlay is an image.
I'm trying to figure out how to create this in HTML and CSS, my experiments so far have seen me play with psuedo elements but am struggling to recreate the design in the shape and position shown below.
My current HTML looks like this:
<header class="main" style="background-image: url(./assets/images/bg-hero.jpg)">
<div class="container">
<div class="row">
<div class="col-12">
<div class="row row--no-pad">
<div class="col-6">
<a href="/">
<img src="./assets/images/logo.png" alt="">
</a>
</div>
<div class="col-6">
</div>
</div>
<div class="row">
<div class="banner">
<div class="row">
<div class="col-12">
<h1>Lorem ipsum dolor sit amet</h1>
<p>Lorem ipsum dolor sit amet lorem ipsum dolor sit amet, L lorem ipsum dolor sit amet.</p>
View our services
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</header>
Here's the design:
Thanks,
Ben
What you're looking for is known as image clipping. There are many articles on the web that cover how to do it with CSS (here is one). The process is really straight forward as it only requires one line of CSS to accomplish this task. You'll need to utilize clip-path in order to get this done, and I highly recommend reading the documentation on it.
Building the clip-path can be difficult depending on what you're going for, but Clippy is an online clip path assistant that is very helpful. However, based on the image you supplied, the following will work:
html, body {
margin: 0;
height: 100%;
background-color: #124;
background-image: linear-gradient(to right, #111, #124);
background-image: -webkit-linear-gradient(to right, #111, #124);
}
.background-image {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/2940219/GIF_Koi_Pond.gif');
background-size: cover;
background-position: center;
clip-path: polygon(56% 0, 78% 50%, 56% 100%, 31% 100%, 52% 50%, 28% 0);
}
.main-content {
position: absolute;
top: 0;
left: 0;
color: #fff;
display: flex;
justify-content: center;
flex-direction: column;
height: 100%;
padding: 15px;
}
.main-content h1 {
width: 250px;
margin: 0;
}
.main-content a {
color: #fff;
background-color: #3a7;
text-decoration: none;
padding: 5px 25px;
width: 150px;
text-align: center;
}
<div class="background-image"></div>
<div class="main-content">
<h1>Lorem ipsum dolor sit amet</h1>
<p>Lorem ipsum dolor sit amet lorem ipsum dolor sit amet, L lorem ipsum dolor sit amet.</p>
View our services
</div>
The part you are the most interested in is:
clip-path: polygon(56% 0, 78% 50%, 56% 100%, 31% 100%, 52% 50%, 28% 0);
Also, don't forget that clip-path has a -webkit version that needs to be accounted for.
clip-path: polygon(56% 0, 78% 50%, 56% 100%, 31% 100%, 52% 50%, 28% 0);
-webkit-clip-path: polygon(56% 0, 78% 50%, 56% 100%, 31% 100%, 52% 50%, 28% 0);
Another thing to remember is that when you apply clip-path to an element such as a div, you're not just clipping the background-image, but rather clipping the entire element.
Image clipping is definitely an option, although if you wanted to go for something more traditional you could use borders like this:
#cutBox{
width: 100%;
height: 600px;
background-image: url('https://wallpaperplay.com/walls/full/7/2/4/272374.jpg');
background-size: cover;
display: flex;
}
#leftPane, #rightPane{
background-color: midnightblue;
}
#leftPane, #rightPane{
height: 100%;
width: 40%;
}
#leftTri{
border-left: 100px solid midnightBlue;
border-top: 300px solid transparent;
border-bottom: 300px solid transparent;
margin-right: 200px;
}
#rightTri{
border-left: 100px solid transparent;
border-top: 300px solid midnightblue;
border-bottom: 300px solid midnightblue;
}
#leftPane > .pane-text{
position: relative;
color: white;
top: 40%;
font-size: 26px;
margin-left: 60%;
right: -10px;
}
.subtext{
margin-left: 20px;
font-size: 18px;
}
<div id="cutBox">
<div id="leftPane">
<div class="pane-text">
Lorem Ipsum
<div class="subtext">
dolor sit amet
</div>
</div>
</div>
<div id="leftTri">
</div>
<div id="rightTri">
</div>
<div id="rightPane">
</div>
</div>
It might look a little odd because of the small viewport but it generally works pretty well.
You can use clip-path property to achieve the affect above.
For example this polygon will create a mask that will create a star shape.
.star {
clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
Here's a tutorial on clip-path
you can also use multiple background with gradient hiding partially another background-image:
* {
margin: 0;
box-sizing: border-box;
}
header {
background: linear-gradient(60deg, rgb(0, 0, 36) 66.6%, transparent 66.66%, transparent 86%, rgb(0, 0, 36) 86.3%) top left no-repeat, linear-gradient(120deg, rgb(0, 0, 36) 66.6%, transparent 66.66%, transparent 86%, rgb(0, 0, 36) 86.3%) bottom left no-repeat, url(https://placeimg.com/640/480/nature/5) center right;
background-size: 100% 50%, 100% 50%, auto;
/*demo purpose*/
position: relative;
display: flex;
justify-content: space-around;
flex-direction: column;
color: white;
max-width: 800px;
min-height:250px;
box-shadow: 0 0 1px;
padding-right: 250px;
margin: auto;
padding-left:1em;
}
body {
background: rgb(0, 0, 36)
}
nav {
position: absolute;
right: 3%;
top: 3em;
border-top: 3px solid;
border-bottom: 3px solid;
}
nav b {
display: block;
width: 2em;
height: 3px;
background: white;
margin: 5px 0
}
<header>
<nav><b></b></nav>
<h1>title</h1>
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est.
thus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus</p>
<a>link</a>
</header>
tune start/stop gradient values to your needs, this is an example.

Is it possible to add an image in the top left corner of a div's border while cutting off the border?

I have this image I am trying to replicate:
Basically, I want the border to go around the image and cut off within a certain distance.
I cannot seem to get the border to cut off.
This is the HTML for this quote and image
<div class="quote-container">
<img class="testimonial-img" src="./Photos/StethoscopeVector.png" alt="">
<div class="quote-container-text">
<h3>Testimonial Quote</h3>
<p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mollis<br/>erat vel ultricies imperdiet. Lorem ipsum dolor sit amet, consectetur<br/>
adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscingelit."
</p>
</div>
</div>
CSS for Quote and Image
.quote-container {
padding: 5em 0;
height: 100%
}
.testimonial-img {
position: absolute;
margin-left: 11.5em;
margin-top: -3em;
}
.quote-container-text {
text-align: center;
color: white;
margin-top: 2em;
border: 2px solid white;
width: 65%;
padding: 2em;
margin: auto;
}
Which currently looks like this image:
I have tried using shape-outside but it doesn't work and I believe it's because the image is being set to absolute.
This is the stethoscope image. White image, no background.
first of all move your image inside of your container-text and then give border to the right and bottom of it and use pseudo selectors :after and :before for the left border and top border.
for more explanation please refer this snippet.
.quote-container {
padding: 5em 0;
height: 100%;
}
.testimonial-img {
position: absolute;
top: -50px;
left: -13px;
}
.quote-container-text {
text-align: center;
color: white;
margin-top: 2em;
border-right: 2px solid white;
border-bottom: 2px solid #fff;
width: 65%;
padding: 2em;
margin: auto;
position: relative;
}
.quote-container-text:before {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 2px;
height: calc(100% - 60px);
background-color: #fff;
}
.quote-container-text:after {
position: absolute;
height: 2px;
width: calc(100% - 100px);
right: 0;
top: 0;
content: "";
background-color: #fff;
}
<body style="background-color: #2196F3">
<div class="quote-container">
<div class="quote-container-text">
<img class="testimonial-img" src="https://i.stack.imgur.com/nj8on.png" alt="">
<h3>Testimonial Quote</h3>
<p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mollis<br/>erat vel ultricies imperdiet. Lorem ipsum dolor sit amet, consectetur<br/>
adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscingelit."
</p>
</div>
</div>
</body>
for background-image instead of bg-color.
.quote-container {
padding: 5em 0;
height: 100%;
background-image: url('https://media.istockphoto.com/photos/vintage-retro-grungy-background-design-and-pattern-texture-picture-id656453072?k=6&m=656453072&s=612x612&w=0&h=4TW6UwMWJrHwF4SiNBwCZfZNJ1jVvkwgz3agbGBihyE=');
background-repeat: no-repeat;
background-size: cover;
}
.testimonial-img {
position: absolute;
top: -50px;
left: -13px;
}
.quote-container-text {
text-align: center;
color: white;
margin-top: 2em;
border-right: 2px solid white;
border-bottom: 2px solid #fff;
width: 65%;
padding: 2em;
margin: auto;
position: relative;
}
.quote-container-text:before {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 2px;
height: calc(100% - 60px);
background-color: #fff;
}
.quote-container-text:after {
position: absolute;
height: 2px;
width: calc(100% - 100px);
right: 0;
top: 0;
content: "";
background-color: #fff;
}
<body>
<div class="quote-container">
<div class="quote-container-text">
<img class="testimonial-img" src="https://i.stack.imgur.com/nj8on.png" alt="">
<h3>Testimonial Quote</h3>
<p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mollis<br/>erat vel ultricies imperdiet. Lorem ipsum dolor sit amet, consectetur<br/>
adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscingelit."
</p>
</div>
</div>
</body>
Thank You...
Your image has a transparent background, and it appears above the border. To fix that, you can set the border on an absolutely positioned pseudo-element (::before), and use clip-path to remove the top left corner:
.quote-container {
padding: 5em;
background: steelblue;
}
.quote-container-text {
position: relative;
width: 65%;
padding: 2em;
margin: auto;
text-align: center;
color: white;
}
.quote-container-text::before {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
border: 2px solid white;
clip-path: polygon(55px 0%, 100% 0%, 100% 100%, 0% 100%, 0% 55px, 55px 55px);
content: '';
}
.testimonial-img {
position: absolute;
top: 0;
left: 0;
transform: translate(-50%, -50%);
}
body {
margin: 0;
}
<div class="quote-container">
<div class="quote-container-text">
<img class="testimonial-img" src="https://i.stack.imgur.com/nj8on.png" alt="">
<h3>Testimonial Quote</h3>
<p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mollis<br/>erat vel ultricies imperdiet. Lorem ipsum dolor sit amet, consectetur<br/> adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscingelit."
</p>
</div>
</div>
An easy way to do this would be to use an image with a background color the same as the background color of the outermost container. Also, it's important to realize that setting something to absolute will make it absolute to the innermost container that has a relative positioning. Note that I used some random image from the web for the example, but you can conform it to your image. If you want your transparent image to have a background, wrap it in a div and set the background of the div.
First move the image inside the quote container text.
<div class="quote-container">
<div class="quote-container-text">
<div id="test-img-container">
<img class="testimonial-img" src="https://cdn3.iconfinder.com/data/icons/medical-174/100/healthy-06-512.png" alt="">
</div>
<h3>Testimonial Quote</h3>
<p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mollis<br/>erat vel ultricies imperdiet. Lorem ipsum dolor sit amet, consectetur<br>
adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscingelit."
</p>
</div>
</div>
Next set the image to absolute with top and left stylings and make the quote-container-text element to be relatively positioned:
.quote-container {
padding: 5em 0;
height: 100%;
background:steelblue;
}
#test-img-container{
position: absolute;
left:-25px;
top:-25px;
background:steelblue;
}
.testimonial-img {
width:50px;
height:auto;
}
.quote-container-text {
text-align: center;
color: white;
margin-top: 2em;
border: 2px solid white;
width: 65%;
padding: 2em;
position:relative;
margin: auto;
}
Also note that this works best if you specify a hard width to the image so that you can evenly use the margin stylings on the image.
https://jsfiddle.net/dgf1ms8r/7/