SVG clipPath not clipping properly properly - html

I am attempting to place a div with a clipPath on top of another div in our footer. Here is an image of what I'm trying to accomplish. In theory, this sounds simple, but I seem to be struggling with the placement and scaling of the clip-path SVG.
The SVG that I am using for the clip is outlined as follows:
<svg height="0" width="0">
<defs>
<clipPath id="clipName" clipPathUnits="objectBoundingBox">
<path class="st0" d="M0,0v258.5l2.9,0.3l636.9,65.3c28.5,2.9,57.2,2.9,85.7,0l637.6-65.3l2.9-0.3l0,73.5h0V0H0z"/>
</clipPath>
</defs>
</svg>
When using the SVG above, I get the following result:
When removing the clipPathUnits="objectBoundingBox", I get the following result:
The last result without the clipPathUnits is what is most confusing, as this is what my SVG looks like (visually):
Here is the current code...
<div class="map-container">
<div class="acf-map">
<div class="marker" data-lat="<?php echo $location['lat']; ?>" data-lng="<?php echo $location['lng']; ?>"></div>
</div>
<div class="map-clip">
<?php echo file_get_contents(get_template_directory_uri() . '/img/map-template.svg'); ?>
</div>
</div>
.map-container {
position: absolute;
left: 0;
right: 0;
top: -15rem;
z-index: 3;
width: 100%;
clip-path: url(#clipName);
.acf-map {
width: 100%;
height: 20rem;
img {
max-width: inherit !important;
}
}
.map-clip {
display: none;
}
}
Am I missing something in my SVG markup, or have I missed some information in terms of placement of clipPaths? Any help would be greatly appreciated.

Huge thank you to #enxaneta for the solution.
I followed the guide here: yoksel.github.io/relative-clip-path
And came up with this for the solution:
<?php echo file_get_contents(get_template_directory_uri() . '/img/map-template.svg'); ?>
<div class="map-container">
<div class="acf-map">
<div class="marker" data-lat="<?php echo $location['lat']; ?>" data-lng="<?php echo $location['lng']; ?>"></div>
</div>
</div>
svg {
position: absolute;
width: 0;
height: 0;
}
.map-container {
position: absolute;
left: 0;
right: 0;
top: -15rem;
z-index: 3;
clip-path: url(#clipName);
.acf-map {
width: 100%;
height: 20rem;
img {
max-width: inherit !important;
}
}
}

Related

Creating an interactive semicircle navigation with HTML and Css

i want to create an interactive wiki with html & css by using a semicircle and dividing the circle into different pieces for each topic. I had the following draft in mind:
https://i.stack.imgur.com/f9Oqp.png
I haven't done html and css in the context of creating own SVGs with animations.
Currently i am using this example as a starting point:
<ul class="menu">
<li class="one">
<a href="#">
<span class="icon">Category 1</span>
</a>
</li>
<li class="two">
<a href="#">
<span class="icon">Category 2</span>
</a>
</li>
<li class="three">
<a href="#">
<span class="icon"> Category 3</span>
</a>
</li>
<svg height="0" width="0">
<defs>
<clipPath clipPathUnits="objectBoundingBox" id="sector">
<path fill="none" stroke="#111" stroke-width="1" class="sector" d="M0.5,0.5 l0.5,0 A0.5,0.5 0 0,0 0.75,.066987298 z"></path>
</clipPath>
</defs>
</svg>
$base: #A5E2F3;
.menu {
padding: 0;
list-style: none;
position: relative;
margin: 30px auto;
width: 70%;
height: 0;
padding-top: 70%;
}
#media all and (max-width: 320px) {
.menu {
width: 230px;
height: 230px;
padding: 0;
}
}
#media all and (min-width: 700px) {
.menu {
width: 500px;
height: 500px;
padding: 0;
}
}
.menu li {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
clip-path: url(#sector);
/* try this one in Chrome/Opera/Safari */
/* clip-path: polygon(50% 50%, 100% 50%, 75% 6.6%); */
a {
display: block;
width: 100%;
height: 100%;
}
&:hover {
background-color: gold;
}
}
.one {
background-color: $base;
transform: rotate(0deg);
}
.two {
background-color: darken($base, 7%);
transform: rotate(-60deg);
}
.three {
background-color: darken($base, 14%);
transform: rotate(-120deg);
}
.icon {
position: absolute;
/* exact values here depend on what you are placing inside the items (icon, image, text, etc.) */
right: 15%;
top: 30%;
/* make sure it it rotated enough; angle of rotation = angle of the sector itself */
transform: rotate(60deg);
/* style further as needed */
color: darken($base, 60%);
font-family: Indie Flower;
font-size: 25px;
}
p {
text-align: center;
width: 80%;
margin: 0 auto;
}
These are my question about this task:
1) How can i create interactive buttons
- click on the button will make the remaining buttons disappear
- 1/3 semicircle will expand to a 1/4 semicicircle
2) How can i improve the clicks with animations
- Button Grows from 1/3 to 1/4 semicircle
Thank you in advance!
To answer your questions:
1). An interactive button can be created in many ways, personally I would do something like this in HTML:
<button type="button" data-toggle="menuItem">Toggle</button>
and then in JavaScript (using jQuery) you can check for when this button is clicked:
$("button[data-toggle='menuItem']").on("click", function () {
// - Do your toggle logic in here
// - Do '.hide()' on all buttons that aren't '$(this)'.
// - Add class to '$(this)' to make it expand.
});
2). It really depends on how you're creating your semi-circles but I would say your best cross-browser solution would be to look into the CSS 'transition' property a bit more: W3Schools CSS transition Property
I hope this helps, let me know if you don't understand something I've said.

Remove the empty space present below the image

we can see lot of empty space in link as below the image. I want to hide those empty space.
.main {
margin: 0 auto;
width: 1000px;
}
body, button, input, select, table, textarea {
font-family: 'Roboto Condensed', sans-serif;
color: #636363;
font-size: 14px;
line-height: 1.5;
}
html
<div class="custom_case">
<div class="custom_case_left">
<h1 class="cc1">Custom Cases</h1>
<h2 class="cc2">Make Your Own design</h2>
</div>
<?php
$brandSelect = '<select id="brand_select">';
$brandSelect .= '<option value="">My Brand</option>';
$brandSelect .= '</select>';
echo '<select id="model_select"><option value="">My Model</option></select>';
?>
<div class ="cc3">
<div class ="cc4">
<span class ="cc5"> See Cases > </span>
</div>
</div>
I dont want to give so much empty space between image and below footer
please help me for this.
Thanks in advance.
Figured it out for you!
Your image of the phone cases is what is causing the space issue.
.custom_case_right img {
/*float:right;*/
/*bottom:320px;*/
}
That will fix the spacing beneath your image. Now your image is displaying improperly and to fix do this
.custom_case_right {
float:right;
margin-top:-310px;
}
These two changes ought to take care of it for you. I tested this out in Chrome.
You'll still need to think about how you want to have your image behave as your viewport shrinks though.
trying to make img:
line-height: 0;
vertical-align: top or bottom;
You have to fix the height of main-container.
enter code here.main-container{
height:550px;
}
Make this changes to your classes:
.col1-layout .col-main {
position: relative;
}
.custom_case_right {
float: left;
position: absolute;
top: 0;
bottom: 0;
right: 0;
}
And in your image remove position absolute, add this style instead:
.custom_case_right img {
position: relative;
width: 620px;
height: 100%;
}

How do I add a image overlay through css?

I need an image overlay for the html I have set up. Below is my code for the "change a profile photo" upload area.
-icon_camera_128.png is the image that needs to be the hover effect.
-img class="cameraUpoad is the default profile photo.
Can someone help me out?
Thanks
<label for="fileUploadLink" class="custom-file-upload">
<div class="changeProfile">
<img src="../img/elements/icon_camera_128.png">
<img class="cameraUpload" style="width: 128px; height: 128px;" src="data:image/png;base64, <?= preg_replace("/\"/", "\\\"", base64_encode($user['avatar'])) ?>" alt="avatar">
<input id="fileUploadLink" type="file" class="filestyle" name="imageUpload" />
You can give a wrap of the images a position: relative; and and the two images (regular state and hovered state) position: absolute; while adjusting opacity of the hovered image:
JS Fiddle
Something like:
.changeProfile {
position: relative;
}
img {
position: absolute;
height: 300px;
width: 300px;
}
.cameraUpload {
opacity: 0;
transition: .4s;
z-index: 999;
}
.cameraUpload:hover {
opacity: 1;
}

Making image hidden with CSS

This image overlays another image. It's added to the page with HTML generated by PHP. This is the PHP code that generates the image:
Echo '<img src="images/tick.png" id="tick' . $i .'" h1 class="hidden" style="position: absolute; top: 30px; left: 70px;"/>';
I want the image to be hidden, and I'll change it to visible when the other image is clicked. This is the CSS:
h1.visible
{
visibility: visible;
}
h1.hidden
{
visibility: hidden;
}
What am I doing wrong?
You're adding your rule to an h1 element rather than an img. And I have no idea what you tried to do with that h1 attribute inside img - get rid of it. Try
echo '<img src="images/tick.png" id="tick' . $i .'" class="hidden" style="position: absolute; top: 30px; left: 70px;"/>';
And CSS:
img.hidden{
visibility: hidden;
}

How to move img src a few pixels down in html page

I found a way to make my own custom file upload control , by placing a fake control over it, and when i click the fake one , i am actually cliking the real control below.
Anyways the image for the browse button is a little to the top.
How can i lower it down a little?
Here is the js fiddle.
JsFiddle
Here is the html and css:
<div>
<div class="fileinputs">
<input type="file" class="file" />
<div class="fakefile">
<input />
<img src="search.jpg" />
</div>
</div>
</div>
div.fileinputs {
position: relative;
}
div.fakefile {
position: absolute;
top: 0px;
left: 0px;
z-index: 1;
}
input.file {
position: relative;
text-align: right;
-moz-opacity:0;
filter:alpha(opacity: 0);
opacity: 0;
z-index: 2;
}
I believe this is what you are looking for. jsFiddle
CSS
.moveimage
{
position: relative;
top: 3px;
}
Modified HTML
<img class="moveimage" src="search.jpg" />