Jump to content

WoHe

Members
  • Posts

    18
  • Joined

  • Last visited

Previous Fields

  • Languages
    HTML, CSS, JavaScript, jQuery, PHP, SQL, Java, Python

Profile Information

  • Gender
    Male
  • Location
    Europe

WoHe's Achievements

Newbie

Newbie (1/7)

2

Reputation

  1. No, but I have tried commenting everything out so it was the same and I saw no difference..
  2. No indeed, when I made the jsfiddle I expected it to lag, but it doesn't, it only lags in my browser via my localhost. (same browser as where I open the fiddle)
  3. Thanks, but it (indeed) doesn't give any visible changes to the lags. I have also commented almost all my other code out to check if that causes the problem, but nothing... I'm testing my site with a localhost (using MAMP), do you know if this can be the problem?
  4. I have created some js file to change the height of my header when a user scrolls through it. The goal is that the header starts at 90% of the window height (90vh in css) when the page is loaded and it shrinks down to 80px when a user starts scrolling down (if the user goes back to the top of the page it will again grow to 90%). Also I want a gif playing in the back behind the header. The code works, but when you scroll down/up it seems to be lagging, but I would like it to fluently do these actions. Can anyone can give me some hints on how to improve the speed? Here is my code for these actions: HTML <html> <body> <div id="header-back" class="col12"></div> <div id="header" class="col12"></div> <div id="main" class="col12"></div> </body> </html> CSS /****** GRID VIEW ******/ [class*="col"] { width: 100%; } @media only screen and (min-width: 850px) { .col1 {width: 8.33%;} .col2 {width: 16.67%;} .col3 {width: 25.00%;} .col4 {width: 33.33%;} .col5 {width: 41.67%;} .col6 {width: 50.00%;} .col7 {width: 58.33%;} .col8 {width: 66.67%;} .col9 {width: 75.00%;} .col10 {width: 83.33%;} .col11 {width: 91.67%;} .col12 {width: 100.00%;} .col {width: auto;} } * { font-family: Trebuchet MS; border: 0px solid black; box-sizing: border-box; } body { width: 100vw; min-height: 100vh; margin: 0; } /* HEADER */ #header { height: 90vh; min-height: 80px; max-height: 90vh; background-color: rgba(30,30,30,0.8); position: fixed; top: 0; left: 0; box-shadow: 0 0 15px rgb(0,0,0); z-index: 2; } #header-back { height: 90vh; min-height: 80px; max-height: 90vh; position: fixed; top: 0; left: 0; z-index: 1; background-image: url("https://media.giphy.com/media/wyBcwFyH2FpO8/giphy.gif"); background-position: bottom left; background-size: cover; } /* MAIN */ #main { min-height: 100vh; padding-top: 90vh; background-color: rgb(230,230,230); } Javascript // change header size on scroll $(document).ready(function(){ // variables var vh90 = $(window).height()*(9/10); var height, color, opacity; // control height of header on scroll $(window).scroll(function(){ height = vh90 - $(window).scrollTop(); opacity = 1 - ( (height-80) / vh90 ) * 0.2; color = "rgba(30,30,30," + opacity + ")"; $("#header").css({"height": height, "background-color": color}); $("#header-back").css({"height": height}); }); }); I have created a jsfiddle to show my idea, but in the fiddle it seems to be working fluently (I used another gif, but I don't think this is the problem because this gif gets loaded at the start and doesn't really go away?)
  5. WoHe

    Grid view does not work

    Oh thanks a lot! I keep making this mistake everywhere...
  6. So the grid view that is explained here does not work in my own document. This is the code I'm using: /*GRID VIEW*/ [class*="col"] { width: 100%; } @media only screen and (min-width: 720px) { .col1 {width: 8,33%;} .col2 {width: 16,67%;} .col3 {width: 25,00%;} .col4 {width: 33,33%;} .col5 {width: 41,67%:} .col6 {width: 50,00%;} .col7 {width: 58,33%;} .col8 {width: 66,67%;} .col9 {width: 75,00%;} .col10 {width: 83,33%;} .col11 {width: 91,67%;} .col12 {width: 100,00%;} } /*LAYOUT*/ * { font-family: sans-serif; border: 0.1px solid black; } body { width: 100vw; height: 100vh; overflow-y: scroll; margin: 0; } div { height: 100px; background-color: red; } <head> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <div class="col3"></div> </body> Does anyone see what's wrong? The div has always a width of 100% in my browser (safari)... Thanks!
  7. So my question is: how can I insert variables into my mysql queries in php? This is my code now, I would like to use the $me and the $friend variables to work in the sql query: function newChat($me, $friend) { global $conn; $sql = "SELECT id FROM chats WHERE (person1 = $me AND person2 = $friend) OR (person1 = $friend AND person2 = $me);"; mysqli_query($conn, $sql) or die('Error querying database.'); echo "check <br />"; $result = mysqli_query($conn, $sql); $row = mysqli_fetch_array($result); while ($row = mysqli_fetch_array($result)) { echo $row['id'] . ' - ' . $row['person1'] . ' - ' . $row['person2'] . ' - ' . $row['date'] .'<br />'; } } newChat('John', 'Marie'); Also if I set $sql to "SELECT * FROM chats" it only gives me one row of my two test rowes in my database. (it only gives the second row, and just ignores the first one? --> a screenshot of the database is at the end of this post) Can anyone please help me with this? Thanks already!
  8. I was wondering if there is any way to set unique values to each cookie. I want to use these cookies on my website to see if the visitor has already visited my website once, but without asking any information from them. This way I want to store this unique value in my database each time someone opens my website, and I will be able to see if there have been - for example - 20 different visitors in the past month, or if the same person has visited my website 20 times. All my code is already written and working, I only need a way to set a different unique value to each cookie I set.
  9. Ok, thanks a lot!
  10. So I have rebuild the code piece by piece and I have found the problem. The problem was in this piece of the code: echo "no cookie found <br />"; I don't know why this would cause a problem, but I don't need it anyway for the actual code, it was just to check if my code works (ironically). I'm still learning php so if you could figure out how this causes a problem, could you please explain it to me? Thanks already!
  11. You could maybe try to float:right the image. I'm also new , but I had a similar problem and it worked when I used this float:right.
  12. I had to set the domain to "localhost" to let the code work, I have now also set an expire date. The only remaining problem is that setcookie($cookiename, $cookievalue, time() + (86400 * 30), "/", "localhost"); doesn't work in an if-statement (as mentioned earlier), it does work outside and inside of any function, but not inside of the if-else statement... For example: This works: setcookie($cookiename, $cookievalue, time() + (86400 * 30), "/", "localhost"); This works: function set($cookiename, $cookievalue) { setcookie($cookiename, $cookievalue, time() + (86400 * 30), "/", "localhost"); } set($cookiename, $cookievalue); But this doesn't work: if(!isset($_COOKIE[$cookiename])) { echo "no cookie found <br />"; setcookie($cookiename, $cookievalue, time() + (86400 * 30), "/", "localhost"); }
  13. Your typed "right:0ox" instead of "right:0px", maybe this causes the problem, also I don't think the "right:0px" is necessary, by using the following code it should be on the bottom of the page and take up all the available width: <div style="bottom: 0px; left: 0px; position: absolute; width 100%; background-color:red;"> Status bar <div></div> </div> Also you used "background:red" instead of "background-color:red".
  14. Could you tell me more specific what you want to do? As I see it, you've got in input field with type=text and you want to copy the text from this input field into another element. I should do this with javascript: var text = document.getElementById("[id of the input field]").value; document.getElementById("[id of the other element]").innerHTML = text;
  15. And what do I need to set the $expires parameter if I don't want it to expire? Also, I don't think localhost is be the issue, because in all the other cases it does work, except for the case where it is set in the if-statement... PS: I've set the expire parameter to time() + (86400 * 30) and it still doesn't work...
×
×
  • Create New...