Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. There is some context missing here. What software are you using? What is a custom field? Is the software actually built in PHP?
  2. Is this an email template? That is the only situation where code like this would be acceptable. To remove spacing from between table cells you can use the border-collapse CSS property like this: <table style="border-collapse:collapse">
  3. The page works for me in IE11 and IE10 on Windows 8, I did not test IE9, but it probably works on it as well. There is probably an issue with how you copied the code.
  4. I don't see an issue with this code. I tested it in Firefox and Chrome, the body element is taking the full width of the window as expected.
  5. Unfortunately, image maps don't scale with the image that they are attached to. The way around it is to create normal <a> elements, wrap them in a container the exact size of the image, then set their position and dimensions using percentage values. It takes a bit of calculating but is achievable.
  6. If you don't have any CSS specifying otherwise, the <html> element should be 1366px on a 1366 monitor. If the width is any smaller than that then there is CSS in your stylsheet that is changing its size. Some of your classes might be affecting the <html> or <body> elements, but I can't tell because I don't know what the HTML of your page looks like. CSS without HTML does not show the whole picture.
  7. A constructor is not required for a class. The constructor is merely a place where you can put code that you want to be executed at the moment the object is instantiated.
  8. Block elements, such as <html>, <body>, <div> and <h1> have the width of their container by default. The container of <body> is <html>, the container of <html> would be the window itself. If a block element with undefined width has margin, padding or borders then these are subtracted from the width so that the sum of the width with these will fit inside the container without the need of a horizontal scrollbar. If you specifically set the width of a block to 100% then this behavior breaks, the width of the content becomes as wide as the container, and then margin, padding and borders are added on top of that, forcing a horizontal scroll bar to appear. You will almost never come across a scenario where the width has to be specifically set to 100% in a normal layout. The regular behavior also breaks if you use float, absolute positioning or flex box. Each of these has their own set of rules for calculating width.
  9. That works if the files are in the same directory as the HTML file. If they're not then you will need to specify the path to the file.
  10. My guess is a problem with the Javascript, but there is not enough information in your post to know for sure. You should check your browser's development tools by pressing F12 and look for Javascript error messages in the console.
  11. It can be centered, but at the cost of losing the scroll bar. CSS can't control scrolling. The structure is simple. We push the left boundary of the image halfway across the container's width, then subtract half of the image's width by translating it. <div class="container"><img src="file.png"></div> .container { position: relative; overflow: hidden; min-height: 100vh } .container > img { display: block; position: absolute; top: 0; left: 50%; transform: translateX(-50%); height: 100vh; width: auto; }
  12. To make it work for multiple images, instead of passing the ID, pass the image itself to the function. The function would start like this: function magnify(element, zoom) { var img, glass, w, h, bw; img = element; // ... Then get a list of images and call the function. It's best if you wait for the images to load before enabling the magnifying glass. I came across a bug where the magnifier wasn't working properly because the image height was zero since the image hadn't loaded yet. Putting all of that together would look like this: <script> var images = document.querySelectorAll(".img-magnifier-container img"); var image; for(var i = 0; i < images.length; i++) { image = images[i]; if(image.complete) { magnify(image, 3); } else { image.addEventListener("load", enableMagnify, false); } } function enableMagnify(e) { magnify(e.currentTarget, 3); } </script> Here's some reading material on some of the things I've used, I suggest you learn about them: addEventListener() currentTarget querySelectorAll()
  13. My screen is 1920 pixels wide. I put your code in a file and tested it in my browser and didn't notice any issue.
  14. Javascript does not work that way. If you want something to appear on the page you have to specify which element will contain it. The closest thing there is to display something where it is invoked is to use document.write(), but that has some serious side effects. You pretty much should never use it.
  15. You might want to take a look at the contents of the $result variable. If the content you're getting from the curl requests is already JSON encoded you actually have to decode them before adding them to the array.
  16. This is not proper JSON, the quotation marks are not properly matched and the word "Array" indicates that you're trying to cast an array to a string. What is the PHP code that generated this output?
  17. Don't do anything in the browser, anybody can hack that. All session information should remain on the server side. You do have to check the $_SESSION variable on every page where the user needs to be logged in.
  18. What do you mean by "garbled"? A background color may not be visible if all of the element's children are floated or given an absolute position. There is no text-color property, it's just called color.
  19. Use the pencil tool or similar, set your tool's color to the specific hex value that you want, then paint the pixel with that color. GIMP and any other image manipulation software, lets you set the color values to perfect precision. If the color picker doesn't show hexadecimal digits then you'll have to type in decimal. 8-bit color channels range from 0 to FF in hexadecimal, which is the same as 0 to 255 in decimal. They are the same precision, just different representations.
  20. If your system requires a login then you should program a login system using a server-side language. If you already have a login system, each page on your site needs to check whether the user is logged in or not. If they are logged in then show the page, otherwise show a "Forbidden access" page or redirect them to the login page.
  21. That's not an object, it's a function that returns an object. The object is inside the function. outerFunction().kir() is just a shorthand for var x = outerFunction(); x.kir();
  22. This does not seem to be an HTML question, it looks like ASP. This syntax is not familiar to me, but if I had to guess what's wrong, I'd say you need to wrap the "CStr" part in <% %> tags.
  23. If the only region on the page that has content is the list of articles itself, I would say the <section> tag is not needed as a direct child of <main>. It's best to give <article> its own <header> to distinguish the article metadata from the article body. If your article is long and has many <h2> - <h6> tags, it would make sense to separate the article itself into sections, one section per sub-heading element as in the following example: <article> <header> <h2>Title</h2> ... Metadata ... </header> <section> <h3>Section 1</h3> <p>Content</p> </section> <section> <h3>Section 2</h3> <p>Content</p> </section> </article> Comment sections could be in the <footer> section of an article, but it could also be placed outside of the <article> element because the content of the comments may potentially not be relevant to the article itself. It would make sense to wrap the comment section in its own <section> tag if it's outside of the article. The truth, though, is that it's not worth overthinking these things because it does not have a major impact on your website. Do your best to make it semantically correct, but don't worry too much about it because there isn't one single correct answer.
  24. When you click on a link it opens a new page with an entirely new Javascript context, everything is lost unless it is saved in a cookie or storage. You can find information about storage here: https://developer.mozilla.org/en-US/docs/Web/API/Storage
×
×
  • Create New...