bottom 0 in IE for all screen size - html

I want my svg images to be on bottom of my block (position:absolute, bottom:0). But in Internet Explorer it doesn't work (displays in the center). I can set width and height to svg and it will work somehow, but it will broke on another device with smaller/bigger screen size. How can I resolve this problem? Thank you!
Here is the code codepen
.wrapper {
padding: 150px 20px 50px;
text-align: center;
color: #fff;
}
.main {
background-color: #000;
line-height: 48px;
position: relative;
}
svg {
position: absolute;
bottom: 0;
}
.left {
left: 0;
}
.right {
right: 0;
}
<div class="main">
<div class="wrapper">
<div class="text">Some text here</div>
<button>click</button>
</div>
<svg class="left" fill="#fff" viewBox="0 0 1300 150" width="50%">
<polygon points="0,0 0,150 1300,150"></polygon>
</svg>
<svg class="right" fill="#fff" viewBox="0 0 1300 150" width="50%">
<polygon points="1300,0 0,150 1300,150"></polygon>
</svg>
</div>

You can achieve the same with using either simple divs or with pseudo elements. The following is an example I created to demonstrate both approaches.
https://codepen.io/Nasir_T/pen/oEYYob
The example uses position along with border to set the bottom design the way your want. You can use the div solution if you want to place images in it or use the pseudo solution if only want to show arrow cut in the design at the bottom.

If you want a background image, why not use a background-image??
.wrapper {
padding: 150px 20px 50px;
text-align: center;
color: #fff;
}
.main {
background-color: #000;
line-height: 48px;
position: relative;
background-image: url('data:image/svg+xml,<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg viewBox="0 0 52 3" xmlns="http://www.w3.org/2000/svg"><polygon points="0,0 26,3 52,0 52,3 0,3" fill="#fff" /></svg>');
background-repeat: no-repeat;
background-position: center bottom;
}
<div class="main">
<div class="wrapper">
<div class="text">Some text here</div>
<button>click</button>
</div>
</div>

This can be accomplished using CSS alone.
We can make triangle shape in CSS. Stick a triangle at the bottom of your main container. Will give the same effect.
.wrapper {
padding: 110px 20px 50px;
text-align: center;
color: #fff;
}
.main {
background-color: #000;
line-height: 48px;
position: relative;
width: 1000px;
}
.arrow-down {
width: 0;
height: 0;
border-left: 500px solid transparent;
border-right: 500px solid transparent;
border-top: 50px solid #000;
position:absolute;
bottom:-50px;
}
svg {
position: absolute;
bottom: 0;
}
.left {
left:0;
}
.right {
right:0;
}
<div class="main">
<div class="wrapper">
<div class="text">Some text here</div>
<button>click</button>
</div>
<div class="arrow-down">
</div>
</div>

Related

How can i set sharp half circle background in css

I am trying to put half circle background but radius in bottom not completely coming in circle....
Here is my code i have tried
.main {
overflow: hidden;
}
.bg {
width: 100%;
height: 800px;
border-bottom-left-radius: 100px;
border-bottom-right-radius: 100px;
background-color: lightgray;
margin-top: -130px;
}
<div class="main">
<div class="bg"></div>
</div>
Try this it's working in all devices
.main{
overflow: hidden;
}
.bg {
width:80vw;
height:40vw;
border-bottom-left-radius: 80vw;
border-bottom-right-radius: 80vw;
background-color: lightgray;
}
<div class="main">
<div class="bg"></div>
</div>
You can use an svg to make things easier. There is the circle element which you can include that always draws perfect circles. Place it so that only the bottom half shows and you've got a half circle.
Example:
svg {
width: 98vw;
height: 98vw;
}
<svg viewbox="0 0 100 100">
<circle cx="50" cy="0" r="50" fill="grey" />
</svg>
.halfCircle{
height:45px;
width:90px;
border-radius: 90px 90px 0 0;
background:green;
}
<div class="halfCircle"></div>
the bellow link has all the shape
https://paulund.co.uk/how-to-create-different-shapes-in-css
As per as you have told your requirements in your comment, I have this.
.main {
/*overflow: hidden;*/
}
.bg {
width: 400px;
height: 500px;
/*Have reduced the width and height just for the sake of simplicity. It's completely up to you */
border-bottom-left-radius: 50%;
border-bottom-right-radius: 50%;
background-color: lightgray;
margin-top: -130px;
}
<div class="main">
<div class="bg"></div>
</div>
Hope this solves your query.
It is working and looking perfectly .But the width should be twice the height and the border-redious first two parameters equal to height and last parameters should be 0
.halfCircle{
height:400px;
width:800px;
border-radius: 400px 400px 0 0;
background:green;
}

Responsive svg content

I need to make the cut out inside the svg respect the same grid as the external content (so it can align with the button outside). The objective is to make the bar support removing or adding buttons as needed.
Codepen
(That is the code, broken on the stackoverflow editor. Can't import bootstrap stylesheet for some reason. check the codepen above)
body {
background: linear-gradient(to right, blue, orange, teal, grey);
margin: 0;
height: 100vh;
width: 100vw;
}
.bar {
position: fixed;
bottom: 0;
height: 65px;
width: 100%;
}
.bar .content {
position: relative;
z-index: 1;
}
.bar .content .btn {
height: 59px;
width: 59px;
background: white;
border-radius: 100%;
}
.bar .content .btn.active {
margin-top: -20px;
}
.bar svg {
position: absolute;
z-index: 0;
width: 100%;
height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
<!--<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>-->
<div class="bar">
<div class="container content" id="html">
<div class="row">
<div class="col-3">
<div class="btn">BTN</div>
</div>
<div class="col-3">
<div class="btn">BTN</div>
</div>
<div class="col-3">
<div class="btn">BTN</div>
</div>
<div class="col-3">
<div class="btn active">BTN</div>
</div>
</div>
</div>
<svg>
<mask id="myMask">
<rect x="0" y="0" width="100%" height="100%" fill="white" />
<circle cx="85%" cy="10" r="36" fill="black" />
</mask>
<rect x="0" y="0" rx="16" width="100%" height="120%" fill="white" mask="url(#myMask)" />
</svg>
</div>
EDIT 1: It needs to be a cut out of the bar, not a trick with colored borders, it was designed to be a transparent space in the shape of a circle. Added colored background to body. Codepen also updated.
You can get the exact same effect using just CSS and flexbox. If you plan on using a shape divider instead of a flat bar there are ways you can shape the bar using purely CSS of if you want to use SVG then simply swap out the the bar CSS below with an SVG, and it should effect the button locations.
You can learn more about how to use flexbox here https://css-tricks.com/snippets/css/a-guide-to-flexbox/
And a guide on how to use shape dividers https://css-tricks.com/creating-non-rectangular-headers/
body {
background: #1a7b6c;
height:100vh;
}
.bar {
position: fixed;
bottom: 0;
height: 65px;
width: 100%;
background:#fff;
}
.bar .row {
width:100%;
display:flex;
flex-direction:row;
justify-content:space-around;
z-index: 1;
}
.bar .btn {
display:flex;
justify-content:center;
align-items:center;
width:60px;
height:60px;
background: white;
text-align:center;
}
.bar .btn.active {
margin-top: -20px;
border:#1a7b6c 10px solid;
border-radius: 100%;
}
<div class="bar">
<div class="row">
<div class="col-3">
<div class="btn">BTN</div>
</div>
<div class="col-3">
<div class="btn">BTN</div>
</div>
<div class="col-3">
<div class="btn active">BTN</div>
</div>
</div>

Different behavior of SVG image in Chrome and IE 11

I have an svg image and I am using flex to center the svg image inside div. svg image is getting properly centered in Chrome, but if I am trying to use the same behavior in IE 11, svg image is getting completely expanded and it covers the entire div.
jsbin link: https://jsbin.com/qufuqekera/1/edit?html,css,output
.svgImage {
width: auto;
display: flex;
align-items: center;
height: 100%;
padding-left: 10px;
padding-right: 10px;
}
svg {
-webkit-transform: scale(2);
transform: scale(2);
-webkit-transform-origin: left;
transform-origin: left;
position: absolute;
border: 1px solid red;
background-color: yellow;
}
.defaultSize {
position: relative;
width: 100%;
height: 100%;
box-sizing: border-box;
border: 1px solid black;
padding-top: 18px;
padding-bottom: 18px;
}
.scroll-bar {
overflow: auto;
position: absolute;
width: 100%;
}
.container {
height: 60vh;
position: relative
}
<div class="container">
<div class="defaultSize">
<div class="scroll-bar" style="height: calc(100% - 36px)">
<div class="svgImage">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1575.01 278.01">
<defs>
<style>.cls-1,.cls-3{fill:#009a38;stroke:#000;stroke-miterlimit:10;}.cls-1{stroke-width:1.01px;}.cls-2{font-size:7px;fill:#f2f2f2;font-family:SiemensSans-Roman, Siemens Sans;}.cls-3{stroke-width:0.99px;}.cls-4{fill:#c8c8c8;}</style>
</defs>
<title>SVG Image</title>
<g id="Layer_2" data-name="Layer 2">
<g id="svgImage" data-name="SVG Image">
<g id="Auto_SVGImage" data-name="Auto_SVGImage">
<g id="Right_Image" data-name="Right Image">
</g>
</g>
</g>
</g>
</svg>
</div>
</div>
</div>
</div>
Screenshot of output in Chrome displaying as expected: https://i.stack.imgur.com/COSm1.png
Screenshot of output in IE 11: https://i.stack.imgur.com/CWxo9.png

Corner DIV with transparent filling

I'm trying to make a corner block, to create a one-page as in the photo below. But I ran into a problem.
I tried to make div slopes, but when looking at different resolutions it looked crooked.
What i need screen
(there was also a problem in that before these inclined divs there was a background image and some holes that left this div, the picture showed through.)My Fail Screen
.tri-index-right {
background: #fff;
height: 150px;
width: 100%;
transform: skewY(4deg);
overflow: hidden;
position: relative;
z-index: 2; /*fail method*/
}
I can not understand how to extend this angle using the CSS method at width 100%.
.1 {
min-width: 500px;
}
#triangle-left {
width: 0;
height: 0;
border-top: 10px solid transparent;
border-right: 100px solid red;
border-bottom: 100% solid transparent;
}
<div class="1">
<div id="triangle-left"></div>
</div>
I will be very grateful for the help
You can use vw for full width or use svg
.one {
width: 100%;
height: 200px;
background: url('https://imgur.com/a/kA3XA') center center no-repeat;
background-size: cover;
}
#triangle-left {
width: 0;
height: 0;
border-top: 100px solid transparent;
border-right: 100vw solid red;
}
<div class="one">
<div id="triangle-left"></div>
</div>
you can also use svg for this
.main {
position: relative;
min-height: 200px;
}
.svg-container svg {
width: 100%;
height: 150px;
fill: #333; /* change color to white since */
}
<div class="main">
<!-- main image -->
</div>
<div class="svg-container">
<svg xmlns="https://www.w3.org/2000/svg" version="1.1" class="separator" viewBox="0 0 100 100" preserveAspectRatio="none">
<path d="M0 100 L100 0 L100 100 Z"></path>
</svg>
</div>
you can also use multiple background image including a sharp gradient :
header {
min-height: 4em;
background:
/* first the mask */
linear-gradient(to bottom right, transparent 49.5%, white 50.5%) bottom left no-repeat,
/* then the background image */
url(http://lorempixel.com/400/300/abstract/1) 0 0;
/* finally resize each image, in particular the mask */
background-size: 100% 4em, cover;
padding: 1em 2em 4em;
color: white;
}
body {
margin: 0;
}
div {
padding: 1em;
}
<header>
<h1>whatever</h1>
</header>
<div>next content</div>

Centered image over split color background in CSS

I've found how to make an image over color background but not when you have two of them. I'd like to center only one image in the middle of the screen/page and I want it to shrink with the window size.
Image example:
body {
font-family: 'Titillium Web', sans-serif;
}
#top,
#bottom {
background: url('http://uxrepo.com/static/icon-sets/zocial/svg/chrome.svg') no-repeat center center;
background-size: cover;
position: absolute;
left: 0;
right: 0;
height: 50%;
}
#top {
top: 0;
background-color: #ff0000;
}
#bottom {
bottom: 0;
background-color: #fff38f;
}
.header-container {
height: 130px;
width: 100%;
margin: 0 auto;
position: absolute;
top: 130px;
}
.header {
text-align: center;
line-height: 16px;
font-size: 48px;
font-weight: 400;
color: #ffffff;
}
.footer-container {
height: 130px;
width: 99%;
margin: 0 auto;
position: absolute;
bottom: 0;
}
.footer {
text-align: center;
line-height: 16px;
}
.img {
position: absolute;
width: 100%;
}
<body>
<div id="top">
<div class="header-container">
<div class="header">
SOME TITLE
</div>
</div>
</div>
<div id="bottom">
<div class="footer-container">
<div class="footer">
some text
<br>
<br>some text
<br>some text
<br>some text
</div>
</div>
</div>
</body>
Does anyone know how to make this result simple?
CSS Gradient
My approach, with a gradient background: JSFiddle
<div class="background">
<img src="source"/>
</div>
.background{
background: linear-gradient(to bottom, #db6062 0%,#db6062 50%,#db6062 50%,#dae27a 50%,#dae27a 100%);
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.background img{
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
height: 200px;
width: 200px;
margin: auto;
}
Svg
Since you are using an svg you can simply use that inline.
And if you put it inline like i have done here in the example below.
You can change all colors in the svg with css.
svg {
height: 100vh;
}
#rect1 {
fill: firebrick;
}
#rect2 {
fill: #229;
}
<div>
<svg viewBox="0 0 500 400">
<rect id="rect1" x="0" y="0" width="1000" height="200" />
<rect id="rect2" x="0" y="200" width="1000" height="200" />
<g transform="translate(150,100) scale(0.2)">
<path d="M0 523q0-75 23-155.5t62-144.5q62-104 182.5-163.5t248.5-59.5q130 0 249.5 81.5t182.5 201.5q50 86 50 214 0 150-71 266t-192 177-270 60q20-36 61-109.5t73.5-130.5 64.5-108l1-2q3-5 12-18.5t12.5-19.5 9.5-17 9.5-21 5.5-21q6-24 6-48 0-80-48-142l275-81q-285 0-428 1-7-1-22-1-99 0-165.5 74t-55.5 173q-2-9-2-28 0-44 15-77l-204-201 198 341q19 72 79.5 117.5t134.5 45.5q17 0 33-3l-66 276q-115 0-223-71t-175-176q-66-102-66-230zm312-19q0 77 54.5 131.5t130.5 54.5 130.5-54.5 54.5-131.5q0-76-54-130.5t-131-54.5-131 54.5-54 130.5z"
/>
</g>
</svg>
</div>