I want to add an image inside the text
so in the section, I add the "heading element" and edit its color to transparent then
add an image inside the "heading element" background from the advance tab and also edit
CSS snippet
selector .elementor-widget-container{
-webkit-background-clip:text;
background-clip: text;
}
but not working, the text didn't appear
I even tried using HTML&CSS code but not working, cleans up the whole section & redo but not working
You can use the background-clip property to achieve what I believe you are going for. Browser support is pretty decent. Read more about it here https://developer.mozilla.org/en-US/docs/Web/CSS/background-clip
EDIT: I see you tried that. You need to have a background property on the same element that you clip.
p {
margin: 1em 0;
padding: 1.4em;
background: url(https://images.pexels.com/photos/1591447/pexels-photo-1591447.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1);
font: 900 2.2em sans-serif;
text-decoration: underline;
}
.text {
background-clip: text;
-webkit-background-clip: text;
color: rgba(0,0,0,.2);
}
<p class="text">THE IMAGE SHOULD SHOW CLIPPED BY THE TEXT</p>
I'm trying to make a heading which has a gradient colour. I've found how to do this online by using '''background-clip: text;'''
However when I try to do this my VS Code does not show a "text" option for background-clip. See below:
VS Code options for background-clip
Why is this not an option for me?
This article helps with explaining it more. Scroll down to the text heading where you can read more about it. It does work, just not how it used to.
.background-clip-text {
/* if we can clip, do it */
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
/* what will show through the text
~ or ~
what will be the background of that element */
background: whatever;
/* fallback text color
~ or ~
the actual color of text, so it better work on the background */
color: red;
}
In order for this to work properly, you will need to apply -webkit-text-fill-color: transparent; to the element you want this style on.
I want to use a font from here. Like you can see, there is a preview image ontop and a small field down below where you can write an example text.
The font is like every other font, meaning only black. Is it possible with css to mimic the texture that is used in the preview image? I mean the dark spots. The white spots that are not on the font can be ignored.
Preview Front with texture
Here is a simple example of text clipping the background of its element using CSS background-clip (note, this is not completely standard and some browsers require a prefix and it is not compatible with IE):
.fontBg {
background-image: url(https://picsum.photos/id/1016/300/100);
background-size: cover;
-webkit-background-clip: text;
background-clip: text;
color: transparent;
font-size: 60px;
font-weight: 900;
font-family: sans-serif;
}
<div class="fontBg">HERE IS SOME TEXT</div>
I'm not really sure why my italic text has a black bg, but p { } is not getting it done and Google just tells me how to make italic text. full css // full html *Edit: You'll see I had to specify background-color for the headers, or they would have #000; bg's as well.
screenshot
The reason you have black background for all the elements even when you don’t specify anything is
{
background-color: #000;
color: #C3CCD3;
font-family: 'Roboto', sans-serif;
box-sizing: border-box; }
Essentially this means that any element in the HTML should have the above properties.
Also remove any #0b0b0b background color from your css. Since this too is almost like black color.
Making text is possible using the tag. And the css should then be written for it as
i {
background-color: red; }
Your question isn't clair at all please provide html with your css not just a screenshot.
All I can see is the * { background-color: #000;} the * stands for Select all elements. So you are basically making eveything with black background.
Also : p { background-color: #0b0b0b; you are making your p elements with black backgrounds since #0b0b0b is also black.
What is the difference to use {text-decoration: underline} and {border-bottom: ...}?
which is easy to style and cross browser compatible?
when we should use border-bottom over text-decoration: underline?
Would it be good to use border-bottom always in place of text-decoration: underline?
border-bottom puts a line at the bottom of the element box. text-decoration:underline renders the text underlined. The exact difference depends on the HTML and text layout engines in use, but in general if you want text underlined, then underline it.
Sorry to say this, but some answers here are misleading. Splitting a line of text does not place the border at the bottom of the entire block, because of the nature of inline blocks. Borders under links are actually more consistent across browsers than text-decoration: underline.
See: Text-Decoration vs. Border-Bottom
As Ignacio said, border-bottom will put the line at the bottom of the containing box, whereas text-decoration:underline will actually underline the text. This becomes an important distinction for multi-line strings.
I am a single line and will look similar for both methods
---------------------------------------------------------
would probably render the same for both styles, but you'll get the following for multi-line strings.
I am a string that has been
split and added a border-bottom
-------------------------------
I am a string that has been
---------------------------
split and underlined
--------------------
Apologies for using code formatting rather than properly rending these examples, but you can see the point I'm trying to make.
bottom-border lets you control the distance between the text and the underline, so its more versatile. And (as mentioned above) it allows a different color for the underline (although I don't see a reason why you'll want to do that).
text-decoration is more 'correct' because it is the 'real' CSS property meant for underlining text.
if you set text-decoration: underline for all links then you will have to set text-decoration: none for special links which you don't need an underline. but if you use border-bottom instead, you'll save one line of CSS code (provide you set text-decoration: none in your reset CSS.
so all in all, i'll vote for border-bottom if you have a complex layout with different styles for each link but text-decoration for a simple website coded 'by the book'.
While there are always going to be cases where one is more appropriate than the other, border-bottom offers much more precise control over text-decoration and is therefore probably the preferred method. Here's a quick (likely not exhaustive) list of properties that border-bottom can control/enable that text-decoration cannot:
Spacing between text and "underline"
"Underline" style (dotted, dashed, solid, gradient, image)
Thickness
CSS transitions/animations
Separation of color between text and "underline"
In many cases, most of these abilities will not be needed - but it is good to have them available! I've switched to using border-bottom primarily for the ability to put a few pixels of padding between the text and the underline; the next most common use I've found is divorcing the underline color from the text color.
With CSS variables now shipping in every major browser, a "reset" stylesheet might look something like this:
:root {
--link-color: blue;
--hover-color: purple;
--underline-color: var(--link-color);
}
a {
color: var(--link-color);
text-decoration: none;
border-bottom: 1px solid var(--underline-color);
}
a:hover {
color: var(--hover-color);
border-bottom-color: var(--hover-color);
}
This way, links will display as expected on a "default" basis, yet still allow for customization as needed.
setting your text to display inline (actually, it should be that by default) will cause the border-bottom to render much as a text-decoration rule.
however, i presume that you want to use this technique on links by doing the following:
/* my super eye catching dual colour link */
a {
color:black;
border-bottom:1px solid red;
}
which is all well and good, but you'll find that wherever you have an img tag inside a link, the image will have a red border under it.
if you can figure out a way to target the parent of a page element (the image) using existing selectors and no javascript, i'll buy you a beer but i don't think you'll have much luck.
using "text-decoration" avoids this issue altogether as an image is clearly not text, it will not render an underline when inside a link.
if you have complete control over your markup, i suppose you can bumble your way through by adding classes to every link, but if you're working with any popular CMS system, you're going to struggle with this idea.
Try this border with 1px image
a:hover {
background: url("img/bg-link-hover.png") repeat-x scroll 0px 92% transparent;
background-color: transparent;
background-image: url("img/bg-link-hover.png");
background-repeat: repeat-x;
background-attachment: scroll;
background-position: 0px 92%;
background-clip: border-box;
background-origin: padding-box;
background-size: auto auto;
}