Donald Wayne Moore II Donald Wayne Moore II - 10 days ago 13
CSS Question

Is there a -webkit for Chrome or a way to get rid of whitespace caused by PHP require_once()?

enter image description here

Okay, so I have this little issue with PHP creating whitespace at the top of my web site when I use

include()
,
include_once()
,
require()
, or
require_once()
. I have figured out how to adjust the positioning of the appropriate elements using the CSS
-webkit
and
-moz
keywords but I can't figure out how to adjust the positioning in Chrome.

I've included a screenshot of three different browsers (Edge, Firefox, and Chrome).

Here is the CSS for the blue
div
on the left side of my web site.

#nav_menu {
position: fixed;
height: 100%;
width: 300px;
background-color: #3C7AF3;
opacity: .6;
padding: 50px 0px 0px 0px;
z-index: 2;
-moz-transform: translateY(-2px);


-moz-transform: translateY(-2px);
worked in Firefox...

• I've tried to fix the whitespace by "converting to UTF-8 w/o BOM" in Notepad++ (it didn't work).

• I need there to be a sort of
-chrome-transform: translateY(-2px);
here but that's not a real code.

• NOTICE:
-webkit-transform: translateY(-20px);
doesn't work for Chrome

}


If I can get rid of the whitespace caused by PHP's require_once() then everything will be fine...

This is on the first line of the web site (account.php):

<?php require_once('../includes/initialize.php'); ?>


This is initialize.php:

<?php
defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR);

defined('SITE_ROOT') ? null :
define('SITE_ROOT' , 'C:'.DS.'wamp64'.DS.'www'.DS.'my_company');

defined('LIB_PATH') ? null : define('LIB_PATH', SITE_ROOT.DS.'includes');

// 1. load config file first
require_once(LIB_PATH.DS."config.php");

// 2. load basic functions next so that everything after can use them
require_once(LIB_PATH.DS."functions.php");

// 3. load core objects
// require_once(LIB_PATH.DS."obj".DS."session.php");
require_once(LIB_PATH.DS."database.php");
require_once(LIB_PATH.DS."obj".DS."database_object.php");

// 4. load database-related classes
require_once(LIB_PATH.DS."obj".DS."user.php");
require_once(LIB_PATH.DS."obj".DS."item.php");
?>


Every single one of those php require_once()'s calls pure PHP.

Here's the kicker: I can comment out (or even delete) the entire initialize.php and it doesn't fix the whitespace.

Here's the code that
require_once()
is supposed to leave in the
<head>
but rather causes the
<head>
tag to end:

enter image description here

Answer

Update: Whitespace is indeed created by BOM. Open file in NotePad++, go to: Encoding -> Convert to UTF-8 and Save file. Make sure you don't select UTF-8 with BOM.

If that doesn't work, try setting top to 0px (it worked for fixed positioning. Otherwise, Chrome is the only (what I would call a third-party) browser that doesn't support -webkit.

#nav_menu {
    position: fixed;
    top: 0px;
    height: 100%;
    width: 300px;
    background-color: #3C7AF3;
    opacity: .6;
    padding: 50px 0px 0px 0px;
    z-index: 2;
}

If that doesn't work, there's a way to fix it with JavaScript:

if (navigator.appVersion.indexOf("Chrome/") != -1) {
var nm = document.getElementById('your_id');
nm.style.top = '-px';
}