CSS property for always on top

There are times that some elements we have in our pages are not displaying the way want it to be. Like one element is covering another elements' part. The example of this is an element which is designed to hide and show   like a dropdown sub-menu usually when it is on showing state it sometimes penetrates another elements thus causing some part of it to be covered. Technically, I found out that their are 2 reasons why this is happening and also 2 solutions to solve it.

1st, The ordering of elements usually causing it. The thing is that the last element will display on the top most so, to solve the problem try to make switching between the element that is affected and the element that is affecting it. But if this is not possible, like a you will ruin your code when you do this or for some reasons that you cannot do changes to it try the second one.

2nd, The element that is affecting the affected element is using has a higher value of z-index property in CSS. So to solve the problem just make sure that the CSS property z-index of your affected element is higher than the CSS property z-index of the element that is affecting it.

It usually looks like this below.

...{
z-index: 10;
}

So, just keep in mind that z-index is the layer position. Its position in layer can be specified though z-index. So, I hope that this would help.

Thank you for reading.

String Between 2 Given Offsets in PHP

I am showing to you another PHP code snippet. Its function is to identify what string is in between 2 given offsets like the starting point and the end point of string which you wanna retrieve. Here is the code.

function strbet($input, $start, $end){
    $substr = substr($input, strlen($start)+strpos($input, $start), (strlen($input) - strpos($input, $end))*(-1));
    return $substr;
}

Now, lets give it a try.

Assuming the following statement:

//You have an input string which you want to process and it so happened that you need to identify what string is in between  2 points there. So,

$my_string = "websitedecoration.blogspot.com";

//And then you wll provide the 2 offset, start and end

//Start position
$start = 0;
//End position
$end = 16;
//call the strbet function
$processed_string = strbet($my_string, $start, $end);

echo $processed_strin;

//Output
websitedecoration


Have a happy coding.

JQuery Vs Plain or Raw Javascript

I just wanna show you how JQuery gets the HTML Object and let us compare how it differs from a plain javascript.

The example below is a code snippet from HTML file. And we are gonna use that as the subject.

<div id="name">Ahmad</div>

Here we go, when a plain javascript needs to read the HTML code snippet above . Let say we need to fetch the name and alert or display it. Then in plain javascript we implement the follwing code to do that.

<script>
            var divObject = document.getElementById("name"); // The parameter value "name" is the id of the HTML tag div above
            var name = divObject.childNodes[0].nodeValue;
            alert(name);
</script>

Now, Lets see how JQuery does it.

<script>
            alert($("#name").val()); //JQuery uses "#" pound sign as indication that it is an "id"
</script>

You will see now how they differed? In JQuery it shortens and simplifies plain javascript expression. But, although it is short you have to keep in mind that it is sometimes a problem when you need to import or include its prerequisite files or library about some kilobytes of data. I find it really annoying sometimes. Specially when i use JQuery in multiple pages. Somehow it messed up your HMTL header. But its worth it sometimes.