Responsive svg content - html

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>

Related

How to create a ban icon from html css?

I am trying to create a ban icon (created from html & css) over an image but I am having a hard time creating it. I have created somewhat static-looking ban icon but it seems perfect and not responsive. Can anyone please guide me on how this can be built?
What i have done so far:
.ban-icon-container{
position: absolute;
top: -10px;
left: 20%;
}
.ban-icon-circle{
width: 290px;
border: 8px solid red;
background: transparent;
height: 290px;
border-radius: 100%;
}
.ban-icon-bar{
height: 1px;
border: 7px solid red;
transform: translate(-1px, -151px) rotate(50deg);
width: 290px;
}
<div class="mt-2 flex align-center">
<div class="m-5 mt-16 mx-auto">
<div class="relative">
<img class="object-contain ban-icon-imgg" src="/img.jpg" alt="img" />
<div class="ban-icon-container">
<div class="ban-icon-circle">
</div>
<div class="ban-icon-bar">
</div>
</div>
</div>
</div>
</div>
Why have you used an attribute named className?
Change the attribute to class and also tweak the marked styles a bit.
Method 1
<style type="text/css">
.ban-icon-container{
position: absolute;
top: -10px;
left: 20%;
}
.ban-icon-circle{
width: 290px;
border: 8px solid red;
background: transparent;
height: 290px;
border-radius: 100%;
}
.ban-icon-bar{
//Change the height to 0px
height: 0px;
border: 7px solid red;
transform: translate(-1px, -151px) rotate(50deg);
//And the width to 240px
width: 240px;
}
</style>
<div class="mt-2 flex align-center">
<div class="m-5 mt-16 mx-auto">
<div class="relative">
<img class="object-contain ban-icon-imgg" src="jpg" alt="img" />
<div class="ban-icon-container">
<div class="ban-icon-circle">
</div>
<div class="ban-icon-bar">
</div>
</div>
</div>
</div>
</div>
Method 2 recommended
You can try using Font Awesome ban icon
I think the best way to create vector icon is SVG. Look at my code this way you can create any icon and this icon will behave like and image. You can scale it accordingly.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Ban Icon</title>
<style>
.ban-icon-container {
position: absolute;
top: 10px;
left: 20%;
}
.ban-icon-circle {
width: 290px;
border: 8px solid red;
background: transparent;
height: 290px;
border-radius: 100%;
}
.ban-icon-bar {
border: 7px solid red;
transform: translate(-1px, -151px) rotate(50deg);
}
</style>
</head>
<body>
<div class="mt-2 flex align-center">
<div class="m-5 mt-16 mx-auto">
<div class="relative">
<img class="object-contain ban-icon-imgg" src="/img.jpg" alt="img" />
<div class="ban-icon-container">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="101" height="101" viewBox="0 0 101 101" preserveAspectRatio="xMidYMid meet">
<circle cx="51" cy="51" r="48" stroke="black" stroke-width="3" fill="none" />
<line x1="17" y1="84" x2="84" y2="17" stroke="black" stroke-width="3" />
</svg>
</div>
</div>
</div>
</div>
</body>
</html>
This is the only code that is creating your ban icon. You can change colors and stroke width
<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="101" height="101" viewBox="0 0 101 101" preserveAspectRatio="xMidYMid meet">
<circle cx="51" cy="51" r="48" stroke="black" stroke-width="3" fill="none" />
<line x1="17" y1="84" x2="84" y2="17" stroke="black" stroke-width="3" />
</svg>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.wrapper {
position: relative;
width: 220px;
height: 220px;
}
img {
width: 100%;
height: 100%;
border-radius: 6px;
}
.ban-icon::before,
.ban-icon::after {
position: absolute;
display: block;
content: '';
width: 70%;
height: 35%;
border-top-left-radius: 100px;
border-top-right-radius: 100px;
border: 10px solid red;
z-index: 1;
}
.ban-icon::before {
top: 15%;
right: -8px;
transform: rotate(45deg);
border-bottom: 10px solid red;
}
.ban-icon::after {
bottom: 15%;
left: -8px;
transform: rotate(-135deg);
border-bottom: 0;
}
<div class="wrapper">
<div class="ban-icon"></div>
<img src="https://www.w3schools.com/html/img_chania.jpg">
</div>

bottom 0 in IE for all screen size

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>

image slide, with div outside of container with overflow hidden

so i have an issue, with an image slider i am trying to build..
above is what i roughly want to achieve.
i have the grey box, which is my wrapper, inside of that, i have a smaller boxes with images, that should not be shown outside of the wrapper as shown on the image.
but the images will have a small button on it, which should expand a div, with info on.
how can i achieve this ?
the expanded div, should also follow the div it belongs to when sliding the image slider..
i have a simple markup so far, but i am unable to produce the desired effect..
not looking for you to write my code, but coded working examples or descriptions as to what could help me achieve my goal, would be helpfull.
.carousel-wrapper {
border: 1px solid red;
width: 100%;
height: 180px;
margin: 40px auto;
.carousel-box-wrapper {
overflow: hidden;
width: 50%;
margin:0 auto;
height:200px;
white-space:nowrap;
transition: none;
transform: translate3d(0px,0px,0px);
.carousel-box {
width:100px;
/*width: calc(100% / 4);*/
padding: 0 10px;
display: inline-block;
vertical-align: top;
margin: 30px 25px;
.carousel-subdiv{
background-color:#a00;
height:1000px;
position:absolute;
top:100px;
}
img.carousel-image {
width:100%;
height: 125px;
}
}
}
.carousel-box-wrapper:before {
content: " ";
width: 20px;
height: 100%;
position: absolute;
top: 0;
z-index: 1;
}
}
<div class="carousel-wrapper">
<div class="carousel-box-wrapper">
<div class="carousel-box">
<img class="carousel-image" src="https://placeholdit.imgix.net/~text?txtsize=9&txt=80%C3%97125&w=80&h=125" />
<div class="carousel-subdiv"></div>
</div>
<div class="carousel-box">
<img class="carousel-image" src="https://placeholdit.imgix.net/~text?txtsize=9&txt=80%C3%97125&w=80&h=125" />
</div>
<div class="carousel-box">
<img class="carousel-image" src="https://placeholdit.imgix.net/~text?txtsize=9&txt=80%C3%97125&w=80&h=125" />
</div>
<div class="carousel-box">
<img class="carousel-image" src="https://placeholdit.imgix.net/~text?txtsize=9&txt=80%C3%97125&w=80&h=125" />
</div>
<div class="carousel-box">
<img class="carousel-image" src="https://placeholdit.imgix.net/~text?txtsize=9&txt=80%C3%97125&w=80&h=125" />
</div>
</div>
</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>

How to add objects in a DIV and appear above the DIV

I am trying to add an image and a textbox inside a DIV that has a opacity of 60%. For some reason the two objects also inherits the opacity as well. How do I prevent it?
HTML:
<body>
<div id="sliderdiv">
<div id="slider">
<img src="i2.jpg" alt="" />
<img src="i3.jpg" alt="Pure Javascript. No jQuery. No flash." />
<img src="i4.jpg" alt="#htmlcaption" />
<img src="i5.jpg" />
</div>
<div id="htmlcaption" style="display: none;">
<em>HTML</em> caption. Link to Google.
</div>
</div>
<div id="bg">
<img src="wmlogo.jpg" width="140" height="30" alt="Westmed Medical Group" title="Westmed Medical Group Homepage" id="logoimg" />
<input type=text size=25 id=insidebgtext />
</div>
</body>
CSS:
* {
background-color: #CC0000;
padding: 0px;
margin: 0px;
}
#bg {
position: absolute;
background-color: #000000;
height: 50px;
width: 100%;
opacity:0.6;
filter:alpha(opacity=60); /* For IE8 and earlier */
z-index: 1;
}
#insidebgtext {
position: absolute;
top: 25%;
right: 20%;
background-color: #FFFFFF;
z-index: 25;
}
#sliderdiv
{
position:absolute;
left:0px;
top:0px;
width: 100%;
height: 306px;
z-index:-1;
background-color: #FCFCFC;
}
#logoimg {
position: absolute;
top: 15%;
left: 25%;
z-index: 25;
}
How it appears:
The inheritance of the properties of parents in the child in very obvious. For your purpose you can use a proxy way of using a transparent png image for the background and avoid the use of opacity all together.