I have a strange blank space in top of one of my divs.
Heres the html:
<!-- ### Bottom content container ### -->
<div class="bottom_content">
<div class="messages"><!-- include problems.php - down devices -->
<?php include "problems.php";?>
</div>
</div>
<!-- ### End bottom content container ### -->
When I examine the output I notice there are two ""after the comment inside the messagesclass. Like this:
<div class="messages"><!-- include problems.php - down devices -->
" "
<?php include "problems.php";?>
</div>
Heres the messages css:
.messages {
display:block;
width: auto;
padding: 10px;
padding-top: -10px; /* Added this to try to remove blank space in top of div */
background: rgb(255, 255, 255); /* The Fallback */
background: rgba(255, 255, 255, 0.5);
-moz-border-radius: 10px;
border-radius: 10px;
border: #ffffff 1px solid;
}
This creates a blank line in top of the div. How can I remove this? I can't find the these two "" anywhere in the code, nor can I find any blank spaces.
EDIT:
Here's the problems.php:
<center><div id="chkerror"></div></center>
This is autofilled with content from a separate php file every 30 seconds using the following jquery:
// <![CDATA[
$(document).ready(function() {
$.ajaxSetup({ cache: false }); // This part addresses an IE bug. without it, IE will only load the first number and will never refresh
setInterval(function() {
$('#chkerror').load('chkIncludes.php');
}, 30000); // the "30000" here refers to the time to refresh the div. it is in milliseconds.
});
// ]]>
And heres the content of chkIncludes.php:
<?php include "chkLoc1.php";?>
<?php include "chkLoc2.php";?>
chkLoc1.php and chkLoc2.php contains :
<?php
$host = "10.10.10.1";
$loc = ("Location 1");
$output = array();
exec("ping -n 1 $host 2>&1", $output);
//you can use print_r($output) to view the output result
if (count($output) > 7) {
$output = null;
$status = ("up");
$formattedstatus = ("<font color='green'><b>$status</b></font>");
}
else {
$output = null;
$status = ("down");
$formattedstatus = ("<font color='red'><b>$status</b></font>");
};
echo ("<div class='$status'><a href='#18/58.99940/5.62324' class='locLink' title='Click to show'><b>$loc</b> <i>(IP: $host)</i> is $formattedstatus</a></div>");
?>
Make sure that problems.php file is encoded without BOM (Byte order mark).
If you're using Notepad++, you can achieve that through:
Encoding > Encode in UTF-8 without BOM
Related
As we all know inline styles are not good practice and they are not compatible with e.g. the Content Security Policy.
This is what I want to achieve without inline styles:
<?php
$spacer_height = 390; // this is a dynamic value from user input could be any integer
?>
<div class="spacer" style="height:<?php echo $spacer_height; ?>"></div>
This is what I want:
HTML:
<?php
$spacer_height = 390; // this is a dynamic value from user input
?>
<div class="spacer spacerheight-<?php echo $spacer_height; ?>" data-height="<?php echo $spacer_height; ?>"></div>
External Stylesheet:
.spacer {
height: spacer_height + "px"; // this line is dummy code
}
Is where a way to achieve this with CSS only. No JavaScript. No Polyfill.
What I have already found is this 5 year old question: CSS values using HTML5 data attribute
However is there a solution meanwhile or is there a CSS solution not using attributes? Is there at least a solution for integers?
Edit: Even a working polyfill may be a welcome answer if there is no other solution.
As you can't do this CSS only (yet, since the attr() function only returns string value), here is a simple script that will do something similar what attr() does, though this parse the data and sets it dynamically using cssText.
Let me know if I got this right
window.addEventListener("load", function() {
var mb = isMobile();
var el = document.querySelectorAll('[data-css]');
for (i = 0; i < el.length; i++) {
var what = el[i].getAttribute('data-css');
if (what) {
what = what.split(',');
el[i].style.cssText = what[0] + ': ' + ((mb) ? what[2] : what[1]) + 'px';
}
}
});
function isMobile() {
//function that check if user is on mobile etc.
return false; // return false for this demo
}
html, body {
margin: 0;
}
div {
background-color: lightgreen;
padding: 10px 0;
height: auto;
box-sizing: border-box;
}
div ~ div {
margin-top: 10px;
}
<div data-css="height,60,30"></div>
<div></div>
<div></div>
<div data-css="height,60,30"></div>
<div></div>
Another option would be to run something server side, where you simply create the CSS rule and class and insert it into CSS file and markup respectively, before sending to the client
You might consider moving the dynamic part from being inline to being referenced in a <style>.
<style>
.spacer {
height:<?php echo $spacer_height; ?>
}
</style>
<?php
$spacer_height = 390; // this is a dynamic value from user input could be any integer
?>
<div class="spacer"></div>
How can I store escaped HTML in an attribute value? If I try to store e.g. > or < in an attribute value on a div, then try to read it back, the browser is unescaping it.
E.g.
HTML
<div id="content" tooltip="Ref: <Unknown>">one fine day in the middle of the night...</div>
<button id="show-tooltip">Show tooltip</button>
JS
var content = document.getElementById('content');
var show = document.getElementById('show-tooltip');
var tooltip;
show.addEventListener('click', function (event) {
if (tooltip) {
document.body.removeChild(tooltip);
}
tooltip = document.createElement('div');
tooltip.classList.add('tooltip');
tooltip.innerHTML = content.getAttribute('tooltip');
tooltip = document.body.appendChild(tooltip);
});
CSS
.tooltip {
width: 100px;
height: 50px;
border: 1px solid rgba(0, 0, 0, .3);
background-color: rgba(255, 255, 0, .3);
}
Fiddle: http://jsfiddle.net/axo25vhy/
I want the tooltip text to display "Ref: <Unknown>", however the text <Unknown> is being converted to an HTML tag so does not appear.
The simplest way is probably to encode the ampersand in < as & => <
http://jsfiddle.net/etoz8o0x/
When your content is appended to the html, the browser decodes & to <. If you encode & correctly as <, the browser decodes < which will then presented visually as a <
I'm creating an automated events display system for a university department that creates posters based on SQL data. The idea is to create both SVG and PDF files of a poster so that the PDF can be used for printing, and the SVG can be displayed on an automatically updating web connected digital signage display (OK, OK, a TV on the wall).
I've got the SVG files formatted how I want them, but when I tried to use the slider libraries to display the .svg files, the formatting of certain elements goes haywire. I've narrowed this down to the fact that SVGs displayed using the IMG tag don't work properly. I've included the file into its own DIV, as it's an HTML5 project; if I move the 'u=image' to the DIV tag, the transition works OK but the SVG breaks once the transition is over (the text origins all seem to reset to upper left).
Just wondered if there was a way of doing this.
<!-- Slides Container -->
<div u="slides" style="cursor: move; position: absolute; left: 0px; top: 0px; width: 764px; height: 1080px; overflow: hidden;">
<?php
// DATA FROM SEMINARS_DETAIL
$query = "SELECT * FROM `seminars_detail` LIMIT 4"; //Date >= NOW()
$result = $mysqli->query($query) or die($mysqli->error.__LINE__);
if($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$sem_id = $row["sem_id"];
$file = "../images/posters/$sem_id.svg";
//SVG not working properly.
echo "<div>";
echo "<img u=\"img\" src=\"$file_th\" />";
echo "</div>";
//Compared with...
//Transition works, but text origin shifts when transition finishes.
echo "<div u=\"image\">";
include $file;
echo "</div>";
}
} else {
echo 'NO RESULTS';
}
?>
</div>
First of all, please disable slideshow.
Also, please try use svg as background image.
<div u="slides" ...>
<div style="background-image: url(l.svg);"></div>
<div style="background-image: url(2.svg);"></div>
<div style="background-image: url(3.svg);"></div>
</div>
I have a php element that I would like to center. At the moment I can only have it either to the right or the left of the page.
<style="text-align: left;"><?php PopupContact(); ?></style>
Is there a simple way of getting this element to sit in the center of the page?
Try this:
<div style="width:300px; margin:auto;"><?php PopupContact(); ?></div>
Where 300px is the width of your popup.
Try setting the text-align to center:
<style="text-align:center;"><?php PopupContact();?></style>
Try this..
You can also use the stylesheet properties like
margin-left:25px; margin-bottom:25px; margin-top:25px; margin-right:25px;
You can change the size of the pixels according to your requirement.
Edit your code exactly for the code which you want to center using:
<center></center>
Edit code which is perhaps with
<?php ?>
As the code in header.php you might need to center only the given code which you want to be centered: Thus giving the exact to use of more <?php codes in the code. Just by centering near exact code by this example:
<center><?php
$code = "code1 to be centered";
?></center>
<?php
$code2 = "code2 which is not centered";
?>
<center><?php
$code3 = "code3 again centered";
?></center>
So perhaps you want to just put into the top of the header.php to be centered with this example:
<center><?php
$code1 "code1 to be centered";
?></center>
<?php
how to add (please wait) on time counter javascript
<script language="javascript">
var timeout,interval
var threshold = <?php global $opt_themes; if($opt_themes['timer_active_']) { ?><?php echo $opt_themes['timer_fake_download']; ?>000<?php } else { ?>3000<?php } ?>;
var secondsleft=threshold;
window.onload = function()
{
startschedule();
}
function startChecking()
{
secondsleft-=1000;
document.querySelector(".div").innerHTML = "<span style=\"padding: 10px 30px;font-size: 40px; display:block;text-align:center;\">" + Math.abs((secondsleft/1000))+" </span>";
if(secondsleft == 0)
{
//document.getElementById("clickme").style.display="";
clearInterval(interval);
document.querySelector(".div").style.display="none";
document.querySelector(".div2").style.display="";
}
}
function startschedule()
{
clearInterval(interval);
secondsleft=threshold;
document.querySelector(".div").innerHTML = "<span style=\"padding: 10px 30px;font-size: 40px; display:block;text-align:center;\"> " + Math.abs((secondsleft/1000))+" </span>";
interval = setInterval(function()
{
startChecking();
},1500)
}
function resetTimer()
{
startschedule();
}
</script>
In my site template I want to place an image code which re-sizes images with a width larger than 910px down to 910px, but leaves those with a width smaller than 910px. If the image is resized it should offer a show original image option.
I would like to implement something like this http://www.mangareader.net/94-8-3/bleach/chapter-1.html
This is the code I have so far:
HTML:
<img src="http://localhost/manga2anime/upload/Bleach/1/03.png" class="resize">
CSS:
.resize {
max-width: 910px;
max-height : auto;
}
Easiest would be if you also stored the img's width in your database. If that's the case, something like this will do:
<?php
// Connect to DB etc.
$result = mysql_query("SELECT 'img_path', 'width' FROM table");
if(mysql_row_count($result) != 0){
while($row = mysql_fetch_array($result)){
$img = "<img src='" . $row['img_path'] . "'";
if($row['width'] > 910){
$img .= " class='resize'";
// OR
// $img .= " width='910'";
echo "<a onclick='showOriginal()'>Show Original</a>";
}
$img .= " >";
echo $img;
}
}else{
echo "No images found.";
}
?>
If the img is already loaded and your php isn't that handy, you can also adjust it with jQuery:
function adjustImage(){
if($('img#needed_img').width() > 910){
$(this).addClass('resize');
// OR
// $(this).attr('width', '910');
$('#show_original_button').show();
}
}
And just call the above function when the document loads (so not in combination with the jQuery ready function). I dont know what your HTML looks like, so its hard to also come up with a working 'show original' function.. but i think something like a lightbox or modal would be most useful in your case to show the original img, for it wont alter your template and just 'sit on top of it'.