tumblr themes + resources

image

How to automatically change icons based on user input

Adding icons to custom links (whether through text options or using {block:HasPages}) can be tricky when you can’t guarantee what users will want their links to be.

Using some attribute selectors, we can change the icon based on the content in the href attribute.

I’m using Font Awesome for this tutorial, but any icon font that uses unicodes in pseudo elements (:before or :after) will work!

My HTML:

{block:HasPages}

<div class=“links”>

{Block:Pages}

<a href=“{URL}”><i class=“fa fa-link”></i> {Label}</a>

{/block:Pages}

</div>

{/block:HasPages}

By default, it will be the link icon. I can change this icon if a user is adding a tag as a link by selecting any link with “/tagged” in its url:

.links a[href*=“/tagged”] i:before {

content:’\f292’;

}

A breakdown of why/how this works and more examples:

Let’s start with the first part

.links a

This is selecting all of the anchor tags inside of our links container

.links a[href*=“/tagged”]

is selecting the href attribute that is inside of a link.

If I were to do

.links a[href=“/tagged”]

it would only select links with that exact match.

by adding the *, i’m selecting any link that contains /tagged somewhere in the link. this way we can select *all* tags, not just one tag at a time.

.links a[href*=“/tagged”] i

This is only selecting the i elements inside of links that contain /tagged. This is important because otherwise we would be selecting every i element, but we only want to change the tag links.

.links a[href*=“/tagged”] i:before

and lastly we are selecting the :before pseudo element that Font Awesome uses to add icons.

What else can I do with this?

You can do a lot with attribute selectors! You could repeat this process for other links like discord, twitch, about pages, faq, etc.

Here is how you would target external links:

a[href^=“https://”]:not([href*=“tumblr.com”])

or if you wanted to include the possibility of http:// you could do either of these:

:where(a[href^=“https://”], a[href^=“http://”]):not([href*=“tumblr.com”])

or

a[href*=“://”]:not([href*=“tumblr.com”])

You can read more about attribute selectors here!

Anonymous asked:

hi! I was reading your common mistakes made in themes and was wondering if you could explain a bit about using classes vs. ids?

Sure!  So classes and IDs are used in very similar ways. 

They are both used to identify elements instead of their tag name (like div, header, etc). Unlike some tags (like h1, a, or blockquote), IDs and classes don’t add any special styling by default, but you can use these selectors to add CSS to those specific elements.

The main difference is that an ID is unique and can only be used once per page. So if you have multiple blog articles, you *can’t* give them all the ID #post. But you can give them the class .post.

For a loose comparison, people can have the same name, but they can’t have the same fingerprints. A class is like an element’s name, which can be used to identify it, but it can also be found on other elements. An ID is like their fingerprint and will only identify that specific element. 

So what happens if you use an ID more than once?

IDs being unique serves a purpose. If you want a link to take you to a specific element, you can link to the ID of that element. For example, if you have something with an ID of footer, add #footer to the end of your url. 

This isn’t possible with classes, even if you only use a class once. This also won’t work if you use an ID more than once.

Otherwise, CSS treats IDs and classes the same, so this might make it seem like it’s not a huge deal. However, JavaScript does NOT treat them the same, and it can and will mess with your scripts. 

When do you use them?

If you don’t need an ID for a link or script, it’s safer to use a class. As I mentioned above, classes work the same way as IDs do in CSS, so if you just need to style something, an ID isn’t necessary. 

I hope this helped!

How to change your ask box colors part 2

In part one of this series, I covered some simple changes like black/white and using hue-rotate to change the colors. With some extra steps, we can change way more than just that.

This is aimed at FAQ pages and anything else where you’re putting your own ask box somewhere, but I will make a tutorial for themes as well!

So first you’ll need 3 things:

  1. A container
  2. A wrapper for your iframe
  3. The ask box iframe

This is how my HTML is set up:

<div class=“ask-container”>
<div class=“ask-wrapper”>
   <iframe frameborder=“0” scrolling=“no"height="190” src=“https://www.tumblr.com/ask_form/{name}.tumblr.com” style=“background-color: transparent; overflow: hidden; height: 190px;” id=“ask_form” contenteditable=“true” data-text=“Enter text here”></iframe>
   </div>
</div>

Here’s the CSS:

.ask-container {
   background:linear-gradient(to left, red, orange, goldenrod, green, blue, purple);
   padding:2px;
}
.ask-wrapper {
   mix-blend-mode:hard-light;
}    

What I’m doing here is making our container have whatever background I want, then making the wrapper with the iframe inside of it essentially act as an overlay that picks up the color behind it. 

Here is the result:

image

Using some of the methods I covered in part one, we can also make semi-transparent ask boxes to go over images, like this:

image

I changed my background for my container to an image instead of a gradient and added some more padding.

Then for the iframe, I applied the filters like in part one:

#ask_form {
filter: invert(84%);
}

You can also do this with a white semi-transparent background by going for a lower percentage.

If you play around with mix-blend-mode, you get results like this too:

image

Please let me know if you have any questions or if you want me to add anything to this tutorial series!

How to change your ask box color

This idea was first mentioned by seraphymns several years ago, but they have since deleted their blog. Since it was hidden behind a read more, the tutorial is gone. 

I was able to find some pieces of what they did, so I’m going to share some variations and similar methods! Keep in mind this will also mess with the icon image, but I don’t think that takes away from the ask box function.

Black/white:

#ask_form {
    filter: grayscale(100%)!important;
}

result:

image

black:

#ask_form {
filter: invert(100%) grayscale(100%)!important;
}

result:

image

Other colors:

by using hue-rotate, you can edit the degrees here to create basically whatever color button you want. Here are some examples:

filter: hue-rotate(60deg); - turns it purple

image

hue-rotate(200deg)  - orange

image

Other methods:

You can also try mix-blend-mode for similar results. However, you will need to apply this to your container, not the ask box itself. This is trickier on regular themes, but can work well with FAQ pages or other pages where you’re making your own ask box.

mix-blend-mode: difference;

will give you this:

image

If I come up with any other examples I’ll make a part 2!

Anonymous asked:

Hi, would you be willing to make a tutorial on how to stylize posts? For example, making ask posts look like iphone messages, making all of the posts the same size without cutting anything off, etc. I've looked everywhere for one, but I can't find anything and my current coding knowledge just isn't enough to figure it out on my own. If you don't have the time, no worries, I just thought I'd ask you because of your amazing coding knowledge!

Hey! 

So this is a little tricky because there’s a ton of ways you can style a post. It would be hard to make just one post about that, but I can make a quick one on iphone messages!

So first you want to set up the HTML for this. It will pretty much look like a regular ask post.

{block:Answer}
           {block:Date}
           <div class=“date”>
             <b>  {ShortDayOfWeek}, {MonthNumber}, {Year}</b> {12Hour}:{Minutes}{AmPm}
           </div>
           {/block:Date}

           <div class=“question”>
               {Asker}:{Question}
           </div>

       {block:Answerer}
        <div class=“reply”>
       {Answerer}: {Answer}
       </div>
       {/block:Answerer}
          <div class=“replies”>
       {Replies}
   </div>
           {/block:Answer}

The date part is optional.

Then we’ll want to create the basic shape of the bubbles

.question, .reply {
   margin-top:20px;
   border-radius: 24px;
   padding:16px;
   background:#eee;
   position:relative;
   width:70%;
   margin-left:30px;
}

I’m selecting both since they’re nearly identical, just opposite sides and different colors.

Speaking of, now we can add that to just the reply class:

.reply {
   background:#147efb;
   color:white;
   margin-left:15%

}

.reply a {
   color:white;
}

Next part is a little tricky if you’re new to CSS. To avoid adding a bunch of extra HTML, we’re  gonna use pseudo elements to style the rest of the bubble. You can read more about them here: https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors/Pseudo-classes_and_pseudo-elements

Here’s the main CSS for the rest of our bubbles:

.question:before, .reply:before {
   content:“;
 position: absolute;
 height: 22px;
 width: 22px;
 background: #eee;
 border-bottom-right-radius: 30px;
 bottom: 0;
}

.question:before {
     left: -8px;
}

.question:after {
    left: -12px;
}
.question:after, .reply:after {
 content:”;
 position: absolute;
 z-index: 1;
 width: 12px;
 height: 22px;
 border-bottom-right-radius: 24px;
 bottom: 0;
 background: {color:posts};
}

Quick breakdown of what’s happening here:

the :before pseudo element is adding a curved square the same color as the bubble, and the :after one is adding a similar curved square on top that matches the background of the post.

Change {color:posts} to whatever you named your color option. Otherwise it will no longer work if the user changes the color of the posts. 

This is going to style the replies so that it appears on the right side of the bubble and flips it horizontally

.reply:after {
   right:-12px;
 transform: scaleX(-1);
}

.reply:before {
   right:-10px;
     transform: scaleX(-1);
         background:#147efb;
}

transform: scaleX(-1);  is a simple way to horizontally flip something!

And lastly we have the (optional) date:

.date {
   text-align:center;
}

This is the final result!

image

You can edit the CSS more to get it a little closer, but this is the general idea. 

I will also be adding a bunch of tutorials to my ko-fi page in the near future, so keep an eye out for those here: https://ko-fi.com/egg !

Editing your theme part 1: getting startedA lot of theme makers, including myself, prefer not to answer most customization asks, but I wanted to cover some ways to edit themes to hopefully make it a bit easier to understand.
Keep in mind that no...

Editing your theme part 1: getting started

A lot of theme makers, including myself, prefer not to answer most customization asks, but I wanted to cover some ways to edit themes to hopefully make it a bit easier to understand. 

Keep in mind that no matter what you’re trying to edit, a basic understanding of HTML and CSS is going to help a lot. You don’t necessarily have to know all of the basics, but try to look up what you’re trying to edit.

For example, if you want to add a background image, there’s a lot more to it than just background:url(’imageurl.png’); depending on what you want to do. This just gets a background image to display. It doesn’t make it cover the whole container or stay attached to the page as you scroll. So, it’s best to do a little research on exactly what you want to do before you jump into editing. 

Once you’ve figured out what and how you want to edit, there are a few different ways to go about this.

First you should double check if there is already an option the theme comes with. Most themes come with color and image options, so if you try to add it yourself it might not work how you want it to if there’s already options available. 

Next step is going to depend on what kind of theme you have. Adding custom CSS is really simple for theme garden themes, but can be a little more complicated if it’s a custom theme not hosted on the theme garden. 

Keep reading

Anonymous asked: Hey, I checked your tags but I couldn't find anything on your theme tutorial where you teach others how to make themes + a basic html lesson. I clicked "start the lessons here" but it keeps redirecting me to your blog and that only. Is it possible that you could give an updated link or a tutorial that teaches similar to what you have?

Yeah I accidentally messed up the link! I need to fix that, but the link is here!

http://eggdesigns.co/howto

and a general one is here

http://eggdesigns.co/htmlbasics

CSS scrollbar tutorial

as requested, here’s quick tutorial on how to make custom scrollbars.

So, a custom scrollbar is only available in webkit browsers (Chrome, Safari, and Opera). This means that any other browser will not display the scrollbar and will just use the default.

In your css, you’ll need, you’ll need to add the pseudo-element ::webkit-scollbar.

A pseudo element is used to style parts of an element. It essentially allows you to create a new type of element that you wouldn’t be able to use normally. this is different from a pseudo class, which adds styling to a specific conditions of an element (like :hover and :nth-child).

So, for a custom scrollbar, you’ll need to include ::webkit-scrollbar to set the width of the scrollbar you’re making. You can also set the height if you want to style a horizontal scrollbar.

 Please do not make your scrollbar tiny. While it’s a common aesthetic in some themes, this makes it very hard to use. You don’t want your users struggling to navigate your theme.

Then you can use ::webkit-track . the track is the background/area that your scrollbar can go up and down.

::webkit-thumb is the part of the scrollbar you click and drag.

With ::webkit-thumb, you can add pseudo classes to it to style it whenever someone hovers over it and/or selects it.

Examples under the cut!

Keep reading