Code Monkey home page Code Monkey logo

firstsite's Introduction

FirstSite

Just playing with HMTL, CSS and JavaScript

Log of errors:

  • The first problem was the width of the table. I wanted it equaled spaced between the cells but also that had a good resizing. The solution that I got was... not good practice I think. I changed the width of every td element in css to be 23%, without messing with the width of the table itself (default: 100%). Somehow everything is working well until now but odd thing happens when I change the percentage value. e.g.: When I put 20% the table gets bigger and when I put above 25% some columns gets bigger, others gets smaller (I think it's because the total sum gets above 100%). The reason why I still using this messing 23% value because if I put a percentage value in the width of the table the smaller version of the page breaks the table, if I put, for example, 290px as the width of the table, it gets a little too big in smaller screens. In the current way the table shrinks in irregular forms, but it still readable in smaller screens. (Question and answers in Stackoverflow)

  • The second problem was how to add 15 methods to each cell of the table to make them change the background color of the page when the mouse hovers over them. As I am a beginner in JavaScript I tried this code:

    for(var i = 1; i < 16; i++){
          celula[i].onmouseover= function(){
            document.body.style.backgroundColor = celula[i].getAttribute("bgcolor");
          }
          celula[i].onmouseout = function(){
            document.body.style.backgroundColor = inicial;
          }
        }

The problem (that right now I don't understand completely) was that I used the keyword "var" in the declaration of the i variable. The correct way is to use the "let" keyword for reasons of different scope (something like this).

  • I committed a type error in the 14ΒΊ cell's attribute. I didn't put the '#' symbol before the hex code of the bgcolor attribute (I discovered on Stackoverflow that bgcolor is a deprecated attribute. I will put the colors with CSS in the future).

  • I tried to set the color of the table cells with classes and CSS instead of using HTML attributes. I couldn't return their colors anymore with cells = getElementsByTagName("td"); cells[i].style.backgroundColor;. After suffering for many hours I discovered the function called "getComputedStyle" that allows you to get the properties inside a class of a element.

firstsite's People

Contributors

arturo32 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.