How target html and css to a specific page? - html

I am using Squarespace as my website builder. I have added a search icon above my blog feed https://www.livingwithphotography.co.uk/learn/ however for some reason the search box also appears on each blog post as well. This is what I don't want, instead I just want it to be shown on this page https://www.livingwithphotography.co.uk/learn/.
In order to code search icon I added this code in the site header
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
I then added this css code
.myTitle {
width: 100px;
padding: 10px;
border: 1px solid grey;
margin: 40px;
font-size: 22px;
text-align: center;
margin-left: auto;
margin-right: auto;
}
Lastly I then added this code to the PAGE HEADER CODE INJECTION
<div class="myTitle"><img src="https://livingwithphotography.squarespace.com/s/Screen-Shot-2015-06-01-at-120646.png" alt="search icon" style="width:20px"> <a href="/search?q=&f_collectionId=5568d109e4b0cb923356090b">Search</div>
<script>
$(document).ready(function() {
$(".myTitle").prependTo("#content");
});
</script>
I hope there is a way, thanks for your help :)

This is a little hacky, but it should work. Wrap the code where you prepend the div in this if.
$(document).ready(function() {
if(window.location.pathname == "/learn") {
$(".myTitle").prependTo("#content");
}
});

Lawrence,
In your CMS (SQ), the type of mod you're wanting here is actually best done in 'developer' mode. Essentially, there's only one collection-ID assigned to the blog itself, which is why when you inject to the main page/content area, it appears across the board as you've noticed. The only differentiating factor is that blog overview pages have added class of "blog-list", while blog entries pages have added class "blog-items" (again, both still contained within the same collection).
So that all said, if you're trying to do this with Jquery in an existing template on a blog module specifically (and you are not toggling into developer), one way to workaround is to target the first instance of the ".entry-header" class on the blog [instead of using 'prependTo' #content].
After targeting the first instance of the entry-header, you would additionally need to also hide the display on the '.blog-items' pages as well (these are the actual entry items themselves). With this approach, your new class "myTitle" should appear only on the blog overview page (in your case: /learn/), but keep it hidden on actual article entry view.
So instead of what you have now, try instead using:
$(document).ready(function() {
$('.myTitle').insertBefore('.entry-header:first');
});
Then in Custom CSS put:
.myTitle {
font-size: 30px;
margin: 40px auto;
padding: 10px;
text-align: center;
width: 201px;
}
.blog-item .myTitle {
display: none;
}
As a note, while it's not totally "proper" form, many just put the whole shebang right into the blog module header since it's page specific and won't run globally.
In that case, you would just input all your code directly into: > Configure Blog > Advanced. Here's a screenshot example (note: shot taken directly from their UI and why the line wraps look funky):
Last note: This method does work, however, bear in mind that if you've manipulated other elements in your site as well (which I wouldn't know if you did) then those other changes could also impact.
Hope this helps.

You could use the Squarespace search block and summary block to do this without any coding:
Just create a new page.
Insert a "search" block and constrain it to only search your blog collection.
Insert a "summary" block and set it to display your existing blog.
Here is an example I set up on my site to demonstrate: http://www.figjamit.com.au/example

Related

Extending Existing HTML Tag Using Classes, Custom Tag, other method?

Edit: Yes I know that what I'm trying to do is convoluted and unnecessary. I assumed that I was missing some fundamental or basic HTML thing that could help me accomplish this, I just don't know enough about HTML/CSS to know what I'm looking for.
I'm relatively new to using HTML (I come from a quantitative background, where I almost exclusively used R and Python). I've probably said one or more things that are nonsensical or wildly incorrect, so please bear with me (and please point out anything I've misstated or gotten completely wrong so I can better my understanding!)
I like using the <details> tag. I've also found it useful for making little footnotes. However, I'd rather not have to specify the particular style characteristics every time I use it for footnotes, and I don't want to specify those characteristics by default using <style> since I do use <details> in other ways, too.
So I thought to make a custom HTML tag that is basically just <details>, but with the particular characteristics I want specifically for footnote-style usage. Ideally (for now), I'd like to do this within an HTML file itself rather than in a separate DOM. I've read a bunch of links on creating custom tags/elements, but I'm missing something to finish it. All of them seem to say that you can declare a new element within an HTML file as follows:
<x-foo></x-foo>
But what goes in between the tags to declare/define x-foo?
My goal is to declare a custom <details-foot></details-foot> corresponding with the following style sheet:
<style>
details {
margin-bottom: 5px
}
details > summary {
padding-top: 0px;
padding-bottom: 0px;
margin-top: 0px;
margin-bottom: 0px;
margin-left: 20px;
font-size: 6pt
}
details > p {
padding-top: 0px;
padding-bottom: 0px;
margin-top: 0px;
margin-left: 20px;
margin-bottom: 0px;
font-size: 6pt
}
</style>
I think I'm just barely missing the piece that I'm looking for, and my HTML knowledge is so limited that I don't know quite what that piece is. I appreciate your patience and help!
Cheers,
Matt
You can set a custom class to use for specific types of formatting within the same document.
More information here
Essentially, you would have it so you have
<details class="foobar">
<summary></summary></details>
And in your header <style> tags (or ideally, in a separate css file), you would have:
.foobar {
[your styling here]
}
This would create a new type of details style.

Proper CSS required to make text and href alignment perfect

I'm new to CSS. I have copied a CSS from existing code and changed as below:
.feedback_h1 {
width: 100%;
float: left;
margin: 0px;
font-family: Arial;
font-size: 12px;
font-width: 400;
color: #000000;
margin-bottom: 15px;
}
<div Class="feedback_h1">
We will use only personal information. Our <a href="https://example.com" target="_blank">privacy
policy</a> agreed?
</div>
Right now I'm getting result as below:
We will use only personal information. Our
privacy policy
agreed?
However, I'm expecting a result like (in one line) :
We will use only personal information. Our privacy policy agreed?
I think, I need a right alignment (as left is aligned properly) OR
Am I missing something in CSS? What additional attribute can I consider in CSS to make this in a single line?
Is VS 2013 provides a designer view to align cshtml page?
It seems as though your <a> anchor element might have a display of block. This will cause the words wrapped between the anchor elements to have a width of 100% by default.
Try putting the following in your css
.feedback_h1 a {
display: inline-block;
}
<a> elements are display: inline by default, so not sure why it might be like this. But from the code, that seems to be the most obvious reason your code is having this result.
To figure out what's going on, I would suggest using your browser's inspector tools and directly inspecting the element. It usually helps with debugging to look at the CSS styles applied to an element, and test by unchecking them, or changing them, to see the live effect of this on your site.

On page CSS to override server added value

We have had a site re-designed by a company who also maintains and hosts it, as well as providing us with our CRM system. The issue I am facing is they add a bit of a backlink to the footer, which I am unable to edit as its not part of the page until the server generates it.
I would like to use On Page CSS to style this to white, or completley remove it. Either is fine
<span style="width: 100%; text-align: center; display: block; color: #999999; font-family: verdana; font-size: 7pt;margin-bottom:4px;">Powered by <a style="color: #999999;" href="http://www.prospectsoft.com/ecommerce" target="_blank">ProspectSoft eCommerce</a> and <a style="color: #999999;" href="http://www.prospectsoft.com/crm" target="_blank">CRM</a></span>
The above is the code I can see when I look at the source of the page in Firefox. I cannot see this code in the editor they provide, however I can edit the css files.
Is it possible to use on page CSS to style this out?
Well in my mind with pure CSS, no since there doesn't seem to be something unique to reference it by.
Alternate Solution:
If you can use Jquery it should be relatively easy though.
Do following in head:
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$().ready(function () {
$('footer').child().hide();
});
</script>
Depending on the build of the page you should be able to isolate that HTML element. For instance, if that span is the only element in the
<footer>
tag, you could simply use:
$('footer').hide();
Note: They may already be referencing jquery, which means you could just do the code.
One More:
$().ready(function () {
$("a:contains('ProspectSoft eCommerce')").parent().hide();
});
Will delete all parents of anchor tags that contain that text though, so be careful.
EDIT:
$("span:contains('Powered by')").hide();
In line CSS will typical override stylesheets declared in the document head.
If you find certain properties remain stubbornly unaffected, try using the "!important" modifier.
Example:
color: #ff0000 !important;
Beyond this, I can't give you any further advice given that you haven't specified exactly what your problem is.
Not good looking but works:
div span, span a { color: #FFF !important; }
Bad thing is you would have to set the color to all other similar nests "div span" and "span a"

Substituting a hard coded label on Volusion (for translations)

I'm working on a project built on Volusion, but unfortunately this platform does not offer full interface edition capabilities so I am trying to edit some labels which are hardcoded into the HTML (I need them to show in spanish).
I tried multiple options discussed in this forum, but so far I am only able to add an alternative text "after" the labels through the CSS; take for example main title on Shopping Cart page (http://pkheu.ahnfg.servertrust.com/ShoppingCart.asp):
/* ========== ORIGINAL LABEL IS "YOUR CART" ============ */
.shoppingcart h2.v65-your-cart-title span {
visibility: hidden;
display: none;
} /*THIS DOESN'T DO ANYTHING AND WITHOUT THE SPAN IT DELETES THE DIV COMPLETELY*/
.shoppingcart h2.v65-your-cart-title:after {
content: " / Su Orden";
margin: 15px 0 0;
visibility: visible;
} /*THIS AT LEAST PERMITS ME TO ADD "/ SU ORDEN" AS A SPANISH ALTERNATIVE*/
Would appreciate any advise on effective way to fully substitute the content on the div on Volusion HTML interface (ie delete the original "Your Cart" from view). Thanks in advance.
Cheers! Max
The easiest way to accomplish what you want without using JavaScript would be to add the following to your template.css file.
h2.v65-your-cart-title { display:none; }
Then simply add the following HTML to the bottom of your article 64 code.
<h2 class="v65-your-cart-title-spanish">Su Orden</h2>

CSS working only on one page but not on the other

I'm making a website for myself (for my jewelry business :) ), for the first time. I can't figure out why css is applyed on one page but not on the other, code for getting css is in both html files the same <link rel="stylesheet" href="shizoid.css"> and they are sharing the same css file.
http://imgur.com/UP3Liae
http://imgur.com/aaGZEa1
You can see on the photos above, for example, in html is tag:
<h1>Extravagant, Unique, Handmade Jewelry and Crafts</h1>
and in css the moderation for it is:
h1 {
background-color: #a018ba;
border-radius: 15px;
font-family: Garamond;
font-size: 40px;
text-align: center;
margin-bottom: 0px;
}
On one page this is working, and on the other isn't. It is like thas from yesterday, it was ok before. I tried to view it both in Firefox and Chrome and on two different computers. I'm looking but I can't see, please help. :)
I have found that it is generally better to apply styles such as borders and backgrounds to a div and then put the h1 into it. For example, your CSS would look something like:
#title-box { width: 800px; margin: 0 auto; background-color: #a018ba; border-radius: 15px; text-align: center; }
h1 { font-family: Garamond; font-size: 40px; }
And your HTML would look like:
<div id="title-box"><h1>Extravagant, Unique, Handmade Jewelry and Crafts</h1></div>
From the photos you posted, I would think that perhaps there is some error elsewhere in your code, such as a without a corresponding that is causing the CSS to not be applied.
Without further information on your website it is hard to determine the actual problem, my first guess is that your second webpage is located in a folder and you haven't updated your CSS.
<link rel="stylesheet" href="../shizoid.css">
If your webpage is on a different folder you can use this href to access the previous directory.
Something is wrong in your idea .It is not css related problem.
Your images are difference. You can see just drag each image and move each image in the browser.You can see that each image has difference.Your whole site is just an image. There is no such kind of tags like you mention <h1>Extravagant, Unique, Handmade Jewelry and Crafts</h1> in your whole html code .Just I posted an image check it either save it in your local drive or drag and drop each image in the new tab browser.
Hope the answer.
I would place the CSS (if it is site wide), in a folder called CSS in your root folder. Then you can simply call the script like this:
<link rel="stylesheet" href="/css/shizoid.css">
From any page...
The initial '/' takes you back to the root of your site.