HTML- Change color text after visited - html

I have the following piece of code where an icon and text are displayed
<div class="group-block last">
<a class="w-inline-block" href="news.html" data-load="1">
<div class="group-image bg3"><img src="images/coffee.png" align="middle"></div>
<div class="group-title">
<div class="title-text">Relaxar-te</div>
</div>
</a>
</div>
I want to change the color of the text "Relaxar-te" after visiting this section. That means, once I returned to this page, the color of the text changed. The CSS of "title-text" is
.title-text {
line-height: 68px;
}
If tried to insert
.title-text:visited {
color: blue;
}
Unfortunately, this doesn't work. I saw many forums where they are using this way, however, it doesn't work for me or I'm missing something.

:visited only works for links. So what you need is
.title-text {
line-height: 68px;
}
a.w-inline-block:visited .title-text {
color: blue;
}
<div class="group-block last">
<a class="w-inline-block" href="news.html" data-load="1">
<div class="group-image bg3"><img src="images/coffee.png" align="middle"></div>
<div class="group-title">
<div class="title-text">Relaxar-te</div>
</div>
</a>
</div>

You can target the text in this manner:
a:visited .title-text{
color: pink;
}
<div class="group-block last">
<a class="w-inline-block" href="news.html" data-load="1">
<div class="group-image bg3"><img src="images/coffee.png" align="middle"></div>
<div class="group-title">
<div class="title-text">Relaxar-te</div>
</div>
</a>
</div>

:visisted only works on the a tag. .title-text is pointed to a div
you could change your code like this to fix it:
.custom-link:visited {
color:blue;
}
<div class="group-block last">
<a class="w-inline-block custom-link" href="news.html" data-load="1">
<div class="group-image bg3"><img src="images/coffee.png" align="middle"></div>
<div class="group-title">
<div class="title-text">Relaxar-te</div>
</div>
</a>
</div>

Related

How to separate div to display on the same line?

I want to separate find an event and post an eventand put them on the same line below Events
Html:
<div class="lasvegas">
Events</div>
<div class="findanevent"> </div>
<div class="event_wrapper"><a href="https://adsler.co.uk/find-an-
event/"><span id="findanevent" class="event">Find an Event</span>.
</a>
<a href="https://adsler.co.uk/post-an-event/"><span id="postanevent"
class="event">Post an Event</span></a></div>
Page:https://adsler.co.uk/events/
Tried css .events {display: block;} didn't work
This worked in mobile but how to replicate in desktop?
.event {float :right;} .findanevent br {display: none;}
.event_wrapper {
text-align: center;
margin-top: 20px;
}
<div class="lasvegas" style="text-align: center">
Events
</div>
<div class="event_wrapper">
<div>
<span id="findanevent" class="event">Find an Event</span>
</div>
<div>
<span id="postanevent" class="event">Post an Event</span>
</div>
</div>

CSS Vertical Align and fancyBox

I am working on a photo gallery(using fancyBox and PHP) for my photography page, and I can't figure out how to make the vertical align for my image gallery to be centered. I currently have placed mock images(from my own gallery) to figure out the layout, and I will then replace them with a PHP query to fill up the gallery with all my content automatically. I have also given each row a (temporary) different color to simply visualize the layout, as well as having a 12 division layout bar at the top for easier handling. The way I currently have my HTML and CSS code set up is as follows:
HTML:
<div class="gallery">
<div class="row row-one">
<div class="col-lg-4">
<a data-type='image' data-fancybox=landscape data-caption=caption href='images/photography/fres/burnaby_mountain.jpg'><img class='img-responsive' src='images/photography/thumbs/burnaby_mountain.jpg'></a>
</div>
<div class="col-lg-4">
<a data-type='image' data-fancybox=landscape data-caption=caption href='images/photography/fres/lions_gate.jpg'><img class='img-responsive' height="500px" src='images/photography/thumbs/lions_gate.jpg'></a>
</div>
<div class="col-lg-4">
<a data-type='image' data-fancybox=landscape data-caption=caption href='images/photography/fres/bubbles.jpg'><img class='img-responsive' src='images/photography/thumbs/bubbles.jpg'></a>
</div>
</div>
</div>
CSS:
.gallery {
display: table;
}
div .row-one {
background-color: red;
display: table-row;
vertical-align: middle;
}
.col-lg-4 {
display: table-cell;
}
As you can see, I have nested the columns inside rows(I did not include the other rows' CSS code, as they're the same except for the background-color attribute, with the intention of automating the gallery later through PHP queries) and rows inside a div container called gallery. From other examples I've seen through looking up for a solution, I've seen people give the main container the display attribute of table, and rows the attribute display: table-row, and lastly the column the table-cell attribute. I have tried this, as well as many other combinations of CSS attributes and have not found a way to center the gallery.
For a better visualization of what I would like to achieve
Thank you for your help, and excuse the lengthy question. I have been searching for a long time and it now feels like something in my code is faulty. I am fairly new to HTML/CSS and although most of my site is working as intended, this is the last bit I need to get it up and running.
Something like this?
.gallery {
display: flex;
height: 30%;
/* flex-direction:column; */
}
.box {
border: 1px solid white;
background: red;
display: flex;
justify-content: center;
flex: 1;
padding: 10px;
}
.inner-box {
align-self: center;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="gallery">
<div class="box">
<div class="inner-box">
<a data-type='image' data-fancybox=landscape data-caption=caption href='images/photography/fres/burnaby_mountain.jpg'><img class='img-responsive' src='https://i.kinja-img.com/gawker-media/image/upload/t_original/bhjivrw2chm9um9yrrmy.jpg'></a>
</div>
</div>
<div class="box">
<div class="inner-box">
<a data-type='image' data-fancybox=landscape data-caption=caption href='images/photography/fres/lions_gate.jpg'><img class='img-responsive' height="500px" src='https://media.gettyimages.com/photos/cocker-spaniel-puppy-picture-id904219284'></a>
</div>
</div>
<div class="box">
<div class="inner-box">
<a data-type='image' data-fancybox=landscape data-caption=caption href='images/photography/fres/bubbles.jpg'><img class='img-responsive' src='http://cdn.bangli.uk/images/201504/article_9323_1.jpg'></a>
</div>
</div>
</div>
<div class="gallery">
<div class="box">
<div class="inner-box">
<a data-type='image' data-fancybox=landscape data-caption=caption href='images/photography/fres/burnaby_mountain.jpg'><img class='img-responsive' src='https://i.kinja-img.com/gawker-media/image/upload/t_original/bhjivrw2chm9um9yrrmy.jpg'></a>
</div>
</div>
<div class="box">
<div class="inner-box">
<a data-type='image' data-fancybox=landscape data-caption=caption href='images/photography/fres/lions_gate.jpg'><img class='img-responsive' height="500px" src='https://media.gettyimages.com/photos/cocker-spaniel-puppy-picture-id904219284'></a>
</div>
</div>
<div class="box">
<div class="inner-box">
<a data-type='image' data-fancybox=landscape data-caption=caption href='images/photography/fres/bubbles.jpg'><img class='img-responsive' src='http://cdn.bangli.uk/images/201504/article_9323_1.jpg'></a>
</div>
</div>
</div>

Color change on hover over multiple elements

I want to apply one for all hover color change effect on the icon, text and button(top to bottom). At the moment hover is working separately either text and icon or button is changing color.
here is the code and also a fiddle
<div class="col-1-left">
<div class="content">
<div class="icon">
<img src="#" />
</div>
<div class="text">
<h4>
Title text
</h4>
</div>
</div>
<div class="button">
Read More
</div>
</div>
.col-1-left {
width: 100%;
background: #555;
padding: 10px;
margin: 0;
color: red;
}
.col-1-left:hover {
color: white;
}
.button a {
color: #000;
}
.button a:hover {
color: white;
}
EDIT:
Although some of the answers worked on jsfiddle, none of them worked so far on live site.. I am pasting updated HTML code structure from it as the one above was only a sample. Maybe that will help sorting this issue out. Thanks!
<div class="et_pb_column et_pb_column_1_3 col-1-left et_pb_column_93 cboxElement">
<div class="et_pb_blurb et_pb_module et_pb_bg_layout_light et_pb_text_align_center mp_m_blurb_pulse fins-color-aqua et_pb_blurb_50 et_pb_blurb_position_top">
<div class="et_pb_blurb_content">
<div class="et_pb_main_blurb_image">
<span class="et-pb-icon et-waypoint et_pb_animation_off et-animated" style="color: #28375c;">?</span>
</div>
<div class="et_pb_blurb_container">
<h4>Title</h4>
<h5>Subhead</h5>
</div>
</div>
</div>
<div class="et_pb_button_module_wrapper et_pb_module et_pb_button_alignment_center">
<a class="et_pb_button et_pb_button_26 et_pb_module et_pb_bg_layout_dark" href="#">Find Out More</a>
</div>
</div>
Please Try this,
.col-1-left:hover * {
color: white;
}
I did a code snippet for you. Please try it and confirm it is what you need.
The thing is that you need to add the hover effect to the parent, i.e. .col-1-left in order to be able to change the color to its children elements.
.col-1-left {
width: 100%;
background: #555;
padding: 10px;
margin: 0;
color: red;
}
.col-1-left:hover, .col-1-left:hover .button a {
color: white;
}
.button a {
color:#000;
}
<div class="col-1-left">
<div class="content">
<div class="icon">
<img src="#" />
</div>
<div class="text">
<h4>Title text</h4>
</div>
</div>
<div class="button">
Read More
</div>
</div>

CSS to change image URL

How can I use an entirely separate CSS file to change/override only the URL for the image IMAGE.png?
<div id="id1" class="class1">
<div id="id2" class="class2">
<div class="class3">
<div id="id3">
<a class="logo" href="http://domain.com" tabindex="-1">
<img src="https://IMAGE.png"></img>
</a>
</div>
</div>
</div>
</div>
Thanks so much!
If you wants to achieve it with css, do it like this (Recommended).
.btn {
display: block;
width: 80px;
height: 80px;
background: url(http://mygimptutorial.com/images/button-with-metal-ring/13.jpg) no-repeat;
background-size: contain;
text-align: center;
color: #fff;
text-decoration: none;
}
.btn:hover {
background: url(http://mygimptutorial.com/images/button-with-metal-ring/8.jpg) no-repeat;
background-size: contain;
}
<div id="id1" class="class1">
<div id="id2" class="class2">
<div class="class3">
<div id="id3">
<a class="btn" href="http://domain.com" tabindex="-1"></a>
</div>
</div>
</div>
</div>
And with js do following.
$('.logo img').hover(function(){
$(this).attr('src','http://mygimptutorial.com/images/button-with-metal-ring/8.jpg');
},function(){
$(this).attr('src','http://mygimptutorial.com/images/button-with-metal-ring/13.jpg');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="id1" class="class1">
<div id="id2" class="class2">
<div class="class3">
<div id="id3">
<a class="logo" href="http://domain.com" tabindex="-1">
<img src="http://mygimptutorial.com/images/button-with-metal-ring/13.jpg"></img></a>
</div>
</div>
</div>
</div>
use content in your dark-mode class
darl
content:url(image.jpg);
You can't change it with CSS, you need Javascript for that.
But if you are trying to change the image on for example hover, you could remove the img-tags and use a div instead on which you set a background-image.
In your CSS you can then create a block where you change the image on hover.

Selecting all but the last element with specific class

I need to apply a style to text in all children divs except the one that has a span with class .fa
.parentDiv > .column :not(.fa) {
font-weight: bold
}
<div class="parentDiv">
<div class="column">aaa</div>
<div class="column">bbb</div>
<div class="column">
<span class="fa">ccc</span>
</div>
</div>
I do need to keep CSS in one line as it's a part of a larger style sheet. How do I do that?
You can use :not with :last-of-type
Snippet
.parentDiv > .column:not(:last-of-type) {
font-weight: bold;
color:red;
}
<div class="parentDiv">
<div class="column">aaa</div>
<div class="column">bbb</div>
<div class="column">
<span class="fa">ccc</span>
</div>
</div>
EDIT based on #Oriol's comment
:not(:last-of-type) does not mean "doesn't contain a .fa
which makes sense, if your code could be dynamic.
here is another approach:
Snippet
.parentDiv > .column span:not(.fa) {
font-weight: bold;
color: red;
}
<div class="parentDiv">
<div class="column">
<span class="gsdfasd">text</span>
</div>
<div class="column">
<span class="faadsasfa">some text</span>
</div>
<div class="column">
<span class="fa">this will NOT BE red</span>
</div>
</div>
The only way to do this is to use
.parentDiv > .column { font-weight: bold }
.parentDiv > .column > .fa { font-weight: normal }
The way the not() selector works is that you have to target a specific element/class/ID. You would have to wrap the text from each column in a span and then add the :not(.fa) CSS to the span:
.parentDiv > .column span:not(.fa) {
font-weight: bold
}
<div class="parentDiv">
<div class="column">
<span>aaa</span>
</div>
<div class="column">
<span>bbb</span>
</div>
<div class="column">
<span class="fa">ccc</span>
</div>
</div>