.lo:link, .lo:visited {
color: #0060b6;
text-decoration: none;
background-color: transparent;
}
<div class="row">
{% for project in projects %}
<div class="col-md-4">
<div class="card mb-4 shadow-sm">
<img src="{{ project.image.url }}" height="250" width="348">
<div class="card-body">
<h4><a class="lo" href="{{ project.url }}">{{ project.title }}</a></h4>
<p class="card-text">{{ project.description }}</p>
<div class="d-flex justify-content-between align-items-center">
</div>
</div>
</div>
</div>
{% endfor %}
</div>
I'm trying to change the stuff in the <a> tag so it's not blue and highlighted.
CSS links are in the right order - bootstrap first, then my own.
I've also tried adding !important after each CSS property doesn't work.
I'm using the Django block content method to have header and footer but that shouldn't make any difference.
You should use id instead of class, because id has a higher priority than class:
#lo:link, #lo:visited {
color: #0060b6;
text-decoration: none;
background-color: transparent;
}
Override the property this way:
.lo:link, .lo:visited {
color: #0060b6;
text-decoration: none;
background-color: transparent;
}
In bootstrap, <a> tag has its own rules which can be overridden easily.
a {
color: #007bff; /* change to the color you want */
text-decoration: none;
background-color: transparent;
}
a:hover {
color: #0056b3; /* change me as you like */
text-decoration: underline;
}
Also, I gave it a try using your style.And it did work for me in a new project which means, you need to check what's preventing it from changing? maybe it's about the CSS specificity
SOLVED! thanks, I really did try everything for 4 agonizing days, it turns out it was in settings.py (using django) STATIC_URL was set to a specific directory so I just had to put my custom css in there, reference that in html and it worked
Related
I'm placing dynamic content on my screen using for loop and jinja templating in flask. I want to change the font color for alternate links placed. I have tried using nth-child as follows, but it doesn't seem to work.
My Code
Dynamic Content in Jinja Template
{% for item in data %}
<div class="removeLink">
<a id="link" href="{{item['link']}}">
<div id="news">{{item['title']}}</div>
</a>
</div>
{% endfor %}
My CSS
#news{
color: white;
font-size: 20px;
margin-bottom: 4%;
margin-top: 1%;
margin-left: 1%;
word-wrap: break-word;
}
.removeLink a{
text-decoration: none;
}
.removeLink:last-child {
margin-bottom: 0px !important;
}
.removeLink:nth-child(2n) {
color: red !important;
}
The #news CSS selector has higher specificity for the link text than the .removeLink:nth-child(2n) selector.
Adjust the selector to create higher specificity. If you're interested, read more about
css specificity.
The following should work:
.removeLink:nth-child(2n) #news {
color: red !important;
}
I figured out the issue in my code so I'm answering my question. I edited my code as follows, with some javascript.
<div id ="holder" class="removeLink">
{% for item in data %}
<a id="link" href="{{item['link']}}">
<div id="news">{{item['title']}}</div>
</a>
{% endfor %}
</div>
<script type="text/javascript">
let elements = document.getElementById("holder").getElementsByTagName('div');
for(let i=0; i<50; i++){
if (i%2 == 0) {
console.log(elements[i]);
elements[i].style.color = "green";
}
}
</script>
a:hover
{
text-decoration: none;
color: #F78888;
}
<link href="https://www.w3schools.com/w3css/4/w3.css" rel="stylesheet" />
<nav class="w3-sidebar w3-collapse w3-top w3-large" style="z-index:100;width:210px;font-weight:bold;" id="mynav">
<div class="w3-container" style="color: white;">
<h3 class="w3-padding-64"><b>No<br>Name</b></h3>
</div>
<div class="w3-bar-block w3-padding-8" style="color: white;">
Courses
Exercises
Rubric
Students
AnyName
Contact
Logout
</div>
</nav>
I am using w3-CSS for my web page. While I apply the hover effect for the 'a' elements it is applying. I can't overwrite the predefined hover effect of the w3-css. I want to change thee text color while hovering the mouse.
That stylesheet you're using is littered with !important declarations including this one at line 144:
.w3-button:hover{color:#000!important;background-color:#ccc!important}
If you want to use a custom color you're unfortunately going to have to declare it the same way using !important. I never advise this if I can help it but, that stylesheet is garbage, so I'm afraid you're not left many choices.
Below is a sample showing this. (I had to add a few other non-relevant styles to get the markup to display in the snipped because nav was display:none. You can ignore those.
/* For demo only */
body {
background-color: #ddd;
}
nav.w3-sidebar.w3-top {
display:block;
background-color: #ccc;
}
/* override !important declarations from W3 stylesheet */
a.w3-button:hover {
color:red !important;
background-color:#ccc !important
}
<link href="https://www.w3schools.com/w3css/4/w3.css" rel="stylesheet" />
<nav class="w3-sidebar w3-collapse w3-top w3-large" style="z-index:100;width:210px;font-weight:bold;" id="mynav">
<div class="w3-container" style="color: white;">
<h3 class="w3-padding-64"><b>No<br>Name</b></h3>
</div>
<div class="w3-bar-block w3-padding-8" style="color: white;">
Courses
Exercises
Rubric
Students
AnyName
Contact
Logout
</div>
</nav>
Make a new class in your stylesheet, e.g:
.myCustomHoverColor:hover {
color: #78cc45 !important;
}
and add it as a class to your <a> element.
so your <a> would look like this:
CoursesĀ“
This worked for me:
<head>
<link href="https://www.w3schools.com/w3css/4/w3.css" rel="stylesheet" />
<style>
.myCustomHoverColor:hover {
color: #78cc45 !important;
}
</style>
</head>
<body>
<nav class="w3-sidebar w3-collapse w3-top w3-large" style="background-color: gray; z-index:100;width:210px;font-weight:bold;" id="mynav">
<div class="w3-container" style="color: white;">
<h3 class="w3-padding-64"><b>No<br>Name</b></h3>
</div>
<div class="w3-bar-block w3-padding-8" style="color: white;">
Courses
Exercises
Rubric
Students
AnyName
Contact
Logout
</div>
</nav>
</body>
.w3-hover-white:hover{color:#000!important;background-color:#fff!important}
Courses
By removing the .w3-hover-white from the a element and gave my own userdefined style.
a:hover
{
text-decoration: none;
background-color: white;
color: #F78888;
}
I'm using BEM and I would like to know how to "disable" a block (.element).
By disable I mean using a different CSS background to emulate a disabled state.
.element {
background-color: #FFF;
}
.element__title {
font-weight: bold;
}
<div id="test" class="element">
<div class="element__title">this is the title</div>
</div>
Should I create
.element--disabled {
background-color: #EEE;
}
and apply that to
<div id="test" class="element element--disabled">
What about the __title? I'm not sure if my approach is correct because I want to overwrite the entire block.
element--disabled will be just fine. For more info see https://en.bem.info/method/naming-convention/#modifier-name
After clicking on either right or left in this carousel, the button remains darker, even after you mouse off the elelemnt. I assume the reason is some sort of visited state, but looking at the CSS, I don't see anything relevant. Is there any way to prevent that effect?
I've written a JSFiddle to demonstrate it, and copied the HTML below.
<div class='container'>
<div class='row'>
<div class='carousel slide' data-interval='false' id='product-image-carousel'>
<!-- Wrapper for slides -->
<center class='carousel-inner'>
<div class='active item'>
<img alt='...' src='http://placehold.it/300x200'>
</div>
<div class='item'>
<img alt='...' src='http://placehold.it/300x200'>
</div>
</center>
<!-- Controls -->
<a class='left carousel-control' data-slide='prev' href='#product-image-carousel' role='button'>
<span class='glyphicon glyphicon-chevron-left'></span>
</a>
<a class='right carousel-control' data-slide='next' href='#product-image-carousel' role='button'>
<span class='glyphicon glyphicon-chevron-right'></span>
</a>
</div>
<!-- Carousel -->
</div>
</div>
Quick workaround: Overwrite bootstrap's css.
.carousel-control:hover,
.carousel-control:focus {
color: #fff;
text-decoration: none;
opacity: .9;
filter: alpha(opacity=90);
}
Remove completely the :focus selector
You can use this workaround:
$(".carousel-control").focus(function(event){
$(this).blur();
});
It works for me.
Simply fix this with css , Decrease the opacity to this .carousel-control:hover, .carousel-control:focus classess , apply the below code your fiddle or your page you can see the difference , Thanks
#product-image-carousel a {
outline: none !important; /* this will remove the outline when we click the anchor tag */
}
.carousel-control:hover, .carousel-control:focus {
opacity: 0.5; /* this will remove the darker color on focus and hover */
}
jsfiddle Update
.carousel-control:focus {
outline: none;
opacity: 0.5;
}
.carousel-control:hover {
opacity: 0.8;
}
<article class="tweet-inner">
<div class="text-wrapper">
<div class="tweet">
<div class="text">
<p>Coming down! Time for Croation BBQ </p>
</div>
<p class="last">
<span class="pull-right">
<small> Hello this is first text </small>
<small> Hello this is second text </small>
</span>
</p>
</div>
</div>
</article>
I have the following repeating html structure.
As of now, I want to provide alternate rows with different background. The element which I want to color is class=text
I do the following in my css -
.tweet-inner .tweet .text-wrapper .text:nth-child(even) {
background-color: #FF0000;
}
This does not work, I also tried -
.text:nth-child(even) {
background-color: #FF0000;
}
This is what works -
article.text:nth-child(even) {
background-color: #FF0000;
}
But I want the .text to be alternately colored, not the entire article.
This also does not work.
The fiddle is http://jsfiddle.net/LKqvz/. Please let me know.
It should be:
article:nth-child(even) .text{
...
}
Because you have multiple article elements with a single .text DIV (your attempts select the nth .text child from article)
Try this
article:nth-child(even) .text {
background-color: red;
}
Js Fiddle
try this:
article:nth-child(even) .tweet .text {
background-color: #FF0000;
}