Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have two images:
<img ng-src="image1.jpg" class="regular">
<img ng-src="image2.jpg" class="favorite">
For the second image, I am looking for a way to structure my CSS class such that a marker/symbol appears over the image (example a star for favorite or just a letter - maybe a drawing). Is there a way to do so?
As <img> element cannot have pseudo content, so you could wrap it into a <span> tag or so into the markup, and apply the pseudo content on it instead.
.favorite {
position: relative;
display: inline-block;
}
.favorite:before {
content: "\2605";
position: absolute;
left: 5px;
top: 5px;
}
<span class="favorite"><img src="//dummyimage.com/100x100"/></span>
Absolute position works.
Try:
With:
.regular {
position: absolute;
left: 0px;
}
.favorite {
position: absolute;
left: 100px;
border: 1px solid black;
}
Code here: https://jsfiddle.net/zyng2Lxj/
as image tag doesn't support after pseudoelement, what about a little jquery code like:
$(function() {
$('.favorite').after('<img src="" class="icon" />');
});
the position the image with the class as in this FIDDLE
(all credit to #Christopher Harris for his answer at Does :before not work on img elements?)
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 months ago.
Improve this question
so I was making a search engine and posting it to the public, but I want the image to move down and center, here's my code:
img {
background-position: bottom 45px bottom;
margin-bottom: 26px;
display: block;
margin-left: auto;
margin-right: auto;
padding: 5px;
outline-style: solid
}
<div id="outline-style">
<div id="margin-bottom">
<img src="https://ci4.googleusercontent.com/proxy/CqUZKaQT0aKsKN4s6QLmO_2lsIoFqxMCpWGdGjA_WFdTcEsdIDEXvDSBl8YT7TwqpUC50zHHq_X-MIy5Onl-WKDjP7IBvoPG-P5CZHr6OmC__zLeZfRJN3v79eqB3GkP6720yegWc9HD_rMfFbsD96v3NYqwFAQgcN09MqY1QqxuCnzPu4QFEGCS5Qt-OLyQwZWMf4E9RdnPkf2QqQPwbXYStw=s0-d-e1-ft#https://dynamic.brandcrowd.com/preview/logodraft/086197e5-30cd-4bd5-abc0-e3ff2882e5a0/image/large.png?bust=ad19d638-d125-45ae-b59a-278e4976924f"
width="200px" height="200px">
</div>
</div
You may adjust the position and padding of the image.
Here's a reference of the difference between margin and padding:
https://www.javatpoint.com/margin-vs-padding#:~:text=tabulated%20as%20follows%3A-,Margin,inside%20of%20the%20element's%20border.
You might need to make it into position: absolute if necessary
Learn more about positioning here:
https://www.w3schools.com/css/css_positioning.asp
Try one of these things:
Position: relative;
top: -10; (maybe +)
or
margin-top: -10%
Add the below property inside the img{} block:
vertical-align: text-bottom;
Refer to this article for more details:
at W3Schools Website
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to create a partial border around these different font headings. How can i create these, please help. I have tried everything but nothing is working. Sorry, noob here
You can't do that with border-top: 10px but you can use pseudo elements like that:
div{
width: 150px;
height: 100px;
background-color: lightgrey;
border-bottom: 5px solid grey;
border-right: 5px solid grey;
}
div:before{
content: '';
width: 70px;
height: 5px;
background-color: grey;
position: absolute;
left: 90px;
}
<div></div>
To be more specific, add :after or :before on your div and add what I added on my example and you can change the height/width/color and make sure to add position:absolute and add some specific properties like top, left..., to position that line where you want.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm trying to create a title where a line is 'beneath' the text as shown here
I'd look similar to a border-bottom, however I cannot figure how I'd move that by the text.
Thank you.
You can use pseudo class to generate the "border" and position it where you want.
span {
font-size: 3rem;
position: relative;
}
span:after {
content: "";
position: absolute;
width: 100%;
height: 10px;
background-color: purple;
bottom: 8px;
left: 0;
z-index: -1;
}
<span>Our Mission</span>
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Hi everyone. I am new to HTML and CSS and I want to create something like the figure in the picture. The two rectangles are divs and I want the left div has a little triangle protruding onto the div on the right.
I would appreciate any help and suggestions.
/**** Edit ****/
Seems like what I am looking for is pseudo-elements! I do not want the triangle to interfere with the content of the right div.
My English is limited so I did not know how to phrase what I want in a Google search.
Thanks a lot for everything!!
You can use a pseudo element :after to add your triangle like this:
.arrow_box {
position: relative;
background: #888;
width: 300px;
height: 300px;
}
.arrow_box:after {
left: 100%;
top: 50%;
border: solid transparent;
content: "";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(0,0,0,0);
border-left-color: #888;
border-width: 30px;
margin-top: -30px;
}
<div class="arrow_box"></div>
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Can some one explain the following css code I found in a web page and which element does the section.positioned affect?
section {
position: relative;
border: 1px solid #000;
padding-top: 37px;
background: #500;
}
section.positioned {
position: absolute;
top: 100px;
left: 100px;
width: 500px;
box-shadow: 0 0 15px #333;
}
Part of web page code
<section class="">
<div class="container">
......
</div>
</section>
The section.positioned rule target an element like this:
<section class="positioned">
</section>
By changing the existing html section element's class from empty to "positioned", the section.positioned rule will apply to the element instead of the section rule.
Added:
What section.positioned really means is it target an element of type "section" which has a class named "positioned".
Further reading about css selectors:
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors
What does the dot mean in CSS?