How to handle border image with transparent background and background image [duplicate] - border

I'm using border-image with a PNG image that has a transparent section. The issue is that the div has background-color set the black. When I apply border-radius, the transparent section of the pattern shows the black of the div and not the background of the element containing the div.
How do I get border-radius to ignore the color of the div. Below is the code in question.
HTML
<header>
<div class="outerColumn">
<div class="column clearfix">
<h1>Company</h1>
<nav>
<ul>
<li>Home</li>
<li>Portfolio</li>
<li>My Work</li>
<li>About me</li>
<li>Elements</li>
<li>Contact</li>
</ul>
</nav>
</div>
</div>
</header>
CSS
body > header {
position:fixed;
top:0;
left:0;
z-index:2;
border-bottom:10px solid #0e0e0e;
-moz-border-image: url(../images/header-background-pattern.gif) 0 0 10 0 repeat;
-webkit-border-image: url(../images/header-background-pattern.gif) 0 0 10 0 repeat;
border-image: url(../images/header-background-pattern.gif) 0 0 10 0 repeat;
}
header, footer {
width:100%;
background-color:#0e0e0e;
clear:both;
}

You can set background-clip to padding-box to set background color size to padding box without border:
-moz-background-clip: padding;
-webkit-background-clip: padding;
background-clip: padding-box;
See http://css-tricks.com/transparent-borders-with-background-clip/ for more informations.

Put the border on a wrapper with transparent background.
<div id="HeaderBorder">
<header>
...
</header>
</div>
<style type="text/css">
#HeaderBorder { /* border image stuff + transparent background */ }
</style>

Related

How to put a gradient on an image in CSS that is not in the background?

I am trying to put gradient on an image that is not loaded from the background. in all the examples I've seen, they load the image from the background and do the gradient, but in my case I don't want to have the background image, and when I add the gradient it doesn't do anything. I show you the HTML code:
<section class="fourth_section">
<h1>Nuevos destinos que descubrir</h1>
<ul class="flex_list">
<li class="picture_list_first">
<figure>
<img src="/img/oporto.jpg" alt="imagen1">
</figure>
<div>
<h3>Oporto</h3>
</div>
</li>
and this is what i tried but it doesn't work:
.picture_list_first img {
width: 330px;
height: 332px;
border-radius: 5px;
margin: 0px -20px 0px -30px;
background: rgb(0,0,0);
background: linear-gradient(0deg, rgba(0,0,0,1) 0%, rgba(255,255,255,1) 100%);
}
Thank you all.
the issue with your code is you are adding a background gradient then covering it up with an image so you cant see the gradient any more.
Im not entirely sure what your aim is however if you want to add a semi transparent gradient to your image, you can do that by adding another element on top of your image and style that with the background property.
it seems this question was already answered here:
How to add a gradient/filter in the image in CSS
You can simply add the background to the parent element (div/anchor/whatever) and then make the image semi transparent. See the snippet below -- hover to see the difference
.gradient-img {
background: rgb(131,58,180);
background: linear-gradient(90deg, rgba(131,58,180,1) 0%, rgba(253,29,29,1) 50%, rgba(252,176,69,1) 100%);
display: flex;
}
.gradient-img img {
opacity: 0.5;
width: 100%;
transition: opacity 500ms 0ms ease-in-out;
}
.gradient-img img:hover { opacity: 1 }
<div class="gradient-img"><img src="https://picsum.photos/200"></div>

How do I make a div like this be able to expand to any size while having the corner triangles stay the same size?

As I said in the title, I want this div to be able to be any size, but without the corner triangles or the line on top getting bigger:
How could I achieve something like this with CSS?
You may use gradients and padding.
possible example
body {
background:linear-gradient(to bottom left , #f8f3e0, silver, #f8f3e0, silver, #f8f3e0, silver, #f8f3e0, silver, #f8f3e0, silver ) ;
}
div {
margin: 1em;
padding: 1.6em 0.5em 1em;
background:
linear-gradient(140deg, transparent 1em, black 1.07em) 0 0 / 1.7em 1.45em no-repeat,
linear-gradient(220deg, transparent 1em, black 1.07em) 100% 0 / 1.7em 1.45em no-repeat,
linear-gradient( to bottom, transparent 1.3em, black 1.3em 1.45em, #e0e5c1 1.45em);
}
div+div {
width: 50vmin;
float: left;
filter:drop-shadow(0 0 1px crimson);
}
div+div+div {
width: 30vmax;
filter: drop-shadow(1px 0px) drop-shadow(-1px 0px) drop-shadow(0 1px); /* a border ? */
}
<div>
<h1>title</h1>
<p>Whatever comes inside</p>
</div>
<div>
<h1>title</h1>
<p>Whatever comes inside</p>
</div>
<div>
<h1>title</h1>
<p>Whatever comes inside</p>
</div>
an idea using clip-path:
.box {
/* adjust the variable to control the clip-path*/
--b:10px;
--c:8px;
/**/
border-top:10px solid #000;
height:100px;
background:#e0e5c1;
clip-path:polygon(var(--b) 0,var(--b) var(--c),calc(100% - var(--b)) var(--c),calc(100% - var(--b)) 0,100% var(--c),100% 100%,0 100%,0 var(--c));
}
<div class="box"></div>

Text goes behind gradient

Im still making a reponsive menu, with scroll controls. I added a gradient on my menu, but I want to, that gradient goes in front of my links and hide them behind it. There's is JSFiddle, you can test it.
There you can see my gradient CSS on my menu
#page .page-nav {
background: white -webkit-linear-gradient(left, transparent 50px, red);
background-size: 40% 100%;
background-repeat: no-repeat;
background-position: right;
}
Any solutions, how to do that?
As far as I know,
You can do it with vendor prefixes and it's not supported in IE (even IE 11)
Unless someone here knows a better way to implement it, I would advise against this.
body {
background: #111;
width: 50%;
margin: 0 auto;
font-size: 50px
}
.page-nav {
background: linear-gradient(to right, #900, #999);
-webkit-background-clip: text;
-moz-background-clip: text;
-webkit-text-fill-color: transparent;
-moz-text-fill-color: transparent;
}
<body>
<p class="page-nav">Sample Sample</p>
</body>

apply hover effect on div but not on h2 inside this

When you hover on div, background-color applies to entire div. I want to exclude h2 and I want to keep the h2 text black without background color.
<style>
.Blog-header-content:hover {
background: rgb(237, 177, 196) none repeat scroll 0 0 important;
opacity: 0.4;
}
h2 {
color: #000;
}
</style>
<div class="Blog-header-content">
hihihihhihhihihihhiihhihih
<h2 class="Blog-title">helloooooooooooooo</h2>
</div>
Actually, all <h></h> tags are inside the <div></div> tag and when you fade its opacity, the texts fades too.
here is a trick to do the the same thing without fading the text.. just remove the opacity tag from div and add opacity to colors.
To show <h2> tag without fade
just change rgb(237, 177, 196) to rgb(237, 177, 196,.4) and remove opacity(0.4) hope this will work
.Blog-header-content:hover{ background: rgba(237, 177, 196,.4) none repeat scroll 0 0 !important ;}
h2{color:#000;}
<div class="Blog-header-content">
hihihihhihhihihihhiihhihih
<h2 class="Blog-title">helloooooooooooooo</h2>
</div>
If you want to show h2 tag without background color then just put it outside that div tag
.Blog-header-content:hover{ background: rgba(237, 177, 196,.4) none repeat scroll 0 0 !important ;}
h2{color:#000;}
<div class="Blog-header-content">
hihihihhihhihihihhiihhihih
</div>
<h2 class="Blog-title">helloooooooooooooo</h2>
Well you can use this to remove background from h2 on hover on div
.Blog-header-content:hover{ background: rgb(237, 177, 196) none repeat scroll 0 0 !important ;opacity:0.4;}
.Blog-header-content:hover h2{ background: #fff!important ;}
h2{color:#000;}
<div class="Blog-header-content">
hihihihhihhihihihhiihhihih
<h2 class="Blog-title">helloooooooooooooo</h2>
</div>
but when it comes on opacity if you reduce opacity of main div then the child elements will also use the parent's opacity.
So if possible you can do it with a bit of html change like this
.Blog-header-content:hover{ background: rgb(237, 177, 196) none repeat scroll 0 0 !important ;}
.Blog-header-content:hover span{ opacity:0.4;}
.Blog-header-content:hover h2{ background: #fff!important ;}
h2{color:#000;}
<div class="Blog-header-content">
<span>hihihihhihhihihihhiihhihih</span>
<h2 class="Blog-title">helloooooooooooooo</h2>
</div>
If you change parent opacity, child opacity property will be from its parent opacity. Eg:
parent{opacity:0.8;}
child{opacity:0.8;} // that's means it is 0.8 of parent opacity, so it's 0.64
So i sugget if it's possible to wrap other content in additional tag, and add opacity attribute to it & additionally set background for h1:
.Blog-header-content:hover{ background: rgba(237, 177, 196,0.4) none repeat scroll 0 0 !important ;}
.Blog-header-content:hover p {opacity:0.4}
h2{color:#000;background:#fff;}
<div class="Blog-header-content">
<p>hihihihhihhihihihhiihhihih</p>
<h2 class="Blog-title">helloooooooooooooo</h2>
</div>
Or just set background only for new tag:
.Blog-header-content:hover p {opacity:0.4;background: rgb(237, 177, 196) none repeat scroll 0 0 !important ;}
h2{color:#000;}
<div class="Blog-header-content">
<p>hihihihhihhihihihhiihhihih</p>
<h2 class="Blog-title">helloooooooooooooo</h2>
</div>

problems with animated background-position-x on different browsers

I've made a simple menu, every item is 300x100 pixels. There's an image in background positioned -150 pixels, when you mouseover an item it changes to 0 (so entire item has background). It works fine on Chrome, the background goes halfway on mouseover on IE, and the background is constantly positioned 0 on FF. How can I fix it?
S
HTML:
<ul class="wrapper">
<li id="webd" class="box"><span class="title">web design</span></li>
<li id="model" class="box"><span class="title">3D modeling</span></li>
<li id="digidraw" class="box"><span class="title">digital drawing</span></li>
<li id="other" class="box"><span class="title">other</span></li>
</ul>
Here's the CSS sample:
.box {
display: block;
position: relative;
width: 300px;
height: 110px;
background-color:black;
z-index: 15;
margin: 2px 2px 2px 2px;
font-family: 'web_serveroffregular';
color:white;
font-size:x-large;
transition: all .5s ease-in-out;
background-position-x:-150px;
background-repeat:no-repeat;
text-align:right;
}
#webd {
background-image:url(images/webd.png);
}
#webd:hover {
background-position-x:0px;
}
You can view the entire website at http://klaunfizia.pl/damian/ and the CSS at http://klaunfizia.pl/damian/style.css and http://klaunfizia.pl/damian/galeria.css
if you want.
#edit
changed:
background-position-x:-150px;
to:
background-position: -150px 0px;
This works fine on FireFox, but still goes only halfway on IE, background:fixed and backgroud-position:fixed ruins it for every browser.
background-position-x is invalid CSS. Use background-position: -150px 0px instead. Also, the background-attachment property must be set to "fixed" for this to work in Firefox and Opera (according to this page at W3Schools)