Percent Based bottom Value doesn't apply on page load - html

I have noticed a weird ... "bug" ...
I have some CSS that looks like this:
.header-slider-text {
bottom: 40%;
color: #fff;
font-size: 22px;
left: 3%;
position: relative
}
This targets some HTML created in my WP plugin code:
$html .= '<div class="top-header-slider full-width-div">';
$html .= ' <div>';
$html .= ' <img src="'. plugins_url('/plugin-name/images/static/1st-slider.jpg') .'"
alt="Some Alt Text" class="img-responsive top-header-img" />';
$html .= ' </div>';
$html .= ' <div>';
$html .= ' <img src="'. plugins_url('/plugin-name/images/static/2nd-slider.jpg') .'"
alt="Some Alt Text" class="img-responsive top-header-img" />';
$html .= ' <div class="header-slider-text" id="second-header-slide-text">';
$html .= ' <p>At the Nurburgring....</p>';
$html .= ' Click here';
$html .= ' <p>and find out why</p>';
$html .= ' </div>';
$html .= ' </div>';
$html .= ' <div>';
$html .= ' <img src="'. plugins_url('/plugin-name/images/static/3rd-slider.jpg') .'"
alt="Some Alt Text" class="img-responsive top-header-img" />';
$html .= ' <div class="header-slider-text" id="third-header-slide-text">';
$html .= ' Click Here';
$html .= ' <p>to see more</p>';
$html .= ' </div>';
$html .= ' </div>';
$html .= '</div>';
However, I've noticed that when I use 40% for my bottom value, on page load it doesn't move my div up 40%. If I changed the value to 333px then it works, everytime. How can I get it to use percentages and work?

absolutely positioned element is displayed on the page in relation to the document this way, using the top, left, bottom and right CSS properties, you can specify an exact position.
try this:
.top-header-slider{
position: relative
}
.header-slider-text {
bottom: 40%;
color: #fff;
font-size: 22px;
left: 3%;
position: absolute
}

Related

Adding space between <span>'s

I'm trying to make each <span> a new paragraph or add a break between each.
Here is my code:
<div class="post_custom_fields">
<?php
if (isset($gt3_theme_pagebuilder['page_settings']['portfolio']['skills']) && is_array($gt3_theme_pagebuilder['page_settings']['portfolio']['skills'])) {
foreach ($gt3_theme_pagebuilder['page_settings']['portfolio']['skills'] as $skillkey => $skillvalue) {
echo "<span>" . esc_attr($skillvalue['value']) . "</span>";
}
}
?>
</div>
Any help would be super appreciated!
Here is a picture of how the info is currently displaying on the website without any spacing between the fields I entered.
Have you thought about using a break?
<div class="post_custom_fields">
<?php
if (isset($gt3_theme_pagebuilder['page_settings']['portfolio']['skills']) && is_array($gt3_theme_pagebuilder['page_settings']['portfolio']['skills'])) {
foreach ($gt3_theme_pagebuilder['page_settings']['portfolio']['skills'] as $skillkey => $skillvalue) {
echo "<span>" . esc_attr($skillvalue['value']) . "</span><br/>";
}
}
?>
</div>
You could use some CSS on the span element
.post_custom_fields > span {
clear:both;
display: block;
margin: 2px 0;
}
I believe what you are asking for is either:
<div class="post_custom_fields">
<?php
if (isset($gt3_theme_pagebuilder['page_settings']['portfolio']['skills']) && is_array($gt3_theme_pagebuilder['page_settings']['portfolio']['skills'])){
foreach ($gt3_theme_pagebuilder['page_settings']['portfolio']['skills'] as $skillkey => $skillvalue) {
echo "<span>" . esc_attr($skillvalue['value']) . "</span><br />";
}
}
?>
</div>
OR
<div class="post_custom_fields">
<?php
if (isset($gt3_theme_pagebuilder['page_settings']['portfolio']['skills']) && is_array($gt3_theme_pagebuilder['page_settings']['portfolio']['skills'])) {
foreach ($gt3_theme_pagebuilder['page_settings']['portfolio']['skills'] as $skillkey => $skillvalue) {
echo "<p>" . esc_attr($skillvalue['value']) . "</p>";
}
}
?>
</div>
echo "<span>" . esc_attr($skillvalue['value']) . "</span> <br>";
or
echo "<p><span>" . esc_attr($skillvalue['value']) . "</span></p>";

Post pictures next to text field PHP

I am creating a form page that will post information for a book (author name, title, press, year, etc.) to an SQL database, and then echo that information back onto the page. An image will also be submitted to a Photos directory and then echoed back onto the page. I am having trouble displaying the images next to the text field without moving the text downwards when a new image is posted.
http://aswanson.net/Work/display.php
<!DOCTYPE html>
<html>
<head>
<title>Display</title>
<style>
img{
margin-left: -50%;
padding-bottom: 50px;
padding-right: 20px;
}
.paragraph{
padding-bottom: 60px;
width: 300px;
}
.info{
margin-top: -40%;
}
</style>
</head>
<body>
<center>
<?php
$con=mysqli_connect("xxxx","xxxx","xxxx");
mysqli_select_db($con, "xxxx");
$getquery=mysqli_query($con, 'SELECT * FROM historytable ORDER BY id DESC');
echo '<div class = "info">';
echo '<div class="pics">';
$images = glob("Photos/*.*");
foreach($images as $image) {
echo '<img src="'.$image.'" /><br />';
}
echo '</div>';
while($rows=mysqli_fetch_assoc($getquery))
{
$id=$rows['id'];
$LastName=$rows['LastName'];
$FirstName=$rows['FirstName'];
$Year=$rows['Year'];
$Press=$rows['Press'];
$Description=$rows['Description'];
$Title=$rows['Title'];
echo '<div class = "paragraph">' . $LastName . '<br/>'. $FirstName . '<br/>' . $Year . '<br/>' . $Press . '<br/>' . $Title . '<br/>'. $Description . '</div>' ;
}
echo '</div>';
?>
</center>
</body>
</html>
Not sure if each image is related to a particular text. But if you want to display text fields beside images regardless of any relation between image and text, add the below css.
.pics{
float:left;
}

Can I make a menu using .row and .col from Bootstrap?

I was trying to make a menu using cols from bootstrap. Something similar to this:
http://i.stack.imgur.com/55xst.png
But I think it's not the best way to make it because I found so much troubles when I tried to implement into Wordpress..
Have some idea how can make it in the right way?
This is my code
HTML:
<div class="container main-menu">
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-3 col-menu logo">
<div class="item-menu">
<figure>
<img src="http://www.sdi-inc-usa.com/image/35012580_scaled_116x87.jpeg" alt="">
</figure>
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-3 col-menu text-center">
<div class="item-menu">
<div class="txt-main-menu">
lorem ipsum
</div>
</div>
</div>
<div class="clearfix visible-xs-block"></div>
<div class="col-xs-6 col-sm-6 col-md-3 col-menu text-center">
<div class="item-menu">
<div class="txt-main-menu">
lorem ipsum & lorem ipsum
</div>
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-3 col-menu text-center">
<div class="item-menu">
<div class="txt-main-menu">
lorem ipsum lorem ipsum lorem ipsum
</div>
</div>
</div>
</div>
</div>
CSS:
.main-menu {
margin-top: 40px;
}
.main-menu > .row > .logo {
text-align: left!important;
}
.main-menu > .row > .col-menu > .item-menu {
background: #f2f2f2;
padding: 10px;
height: 107px;
font-size: 1.375em;
position: relative;
}
.main-menu > .row > .col-menu > .item-menu:hover {
background: #bcd22c;
}
.txt-main-menu > a {
font-family: 'museo-700';
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
padding: 25px 25px;
text-decoration: none;
color: #565656;
}
.col-menu {
padding-left: 0px;
padding-right: 5px;
padding-bottom: 5px;
}
/** END Main Menu - LOGO*/
#media screen and (max-width: 767px) {
div.col-menu:nth-child(2n+3),
div.col-news:nth-child(2n+3),
div.col-menu:nth-child(2),
div.col-news:nth-child(2) {
padding: 0;
}
.col-grid {
padding-right: 0;
}
}
Thank you
I'd suggest you use the "navbar" component. It is purpose build for this type of thing.
http://getbootstrap.com/components/#navbar
I found this bootsrap to wordpress series online http://bootstrapwp.com/adding-bootstrap-menu-wordpress-theme/ It is a excellent course for combining bswp.
The first step is to add a custom Walker menu to create the Bootstrap menu for the WordPress theme. We will then go over how to add the custom menu to the header of our WordPress theme and some minor customization options. You will also learn how make sure the menu has all the markup needed to be responsive and support child menu items.
Create a new file called bootstrap-walker.php in the /inc/ directory
In this file add the following code:
<?php
// Custom Walker Class for Bootstrap Menu
add_action( 'after_setup_theme', 'bootstrap_setup' );
if ( ! function_exists( 'bootstrap_setup' ) ):
function bootstrap_setup(){
class Bootstrap_Walker_Nav_Menu extends Walker_Nav_Menu {
function start_lvl( &$output, $depth ) {
$indent = str_repeat( "\t", $depth );
$output .= "\n$indent<ul class=\"dropdown-menu\">\n";
}
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$li_attributes = '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$classes[] = ($args->has_children) ? 'dropdown' : '';
$classes[] = ($item->current || $item->current_item_ancestor) ? 'active' : '';
$classes[] = 'menu-item-' . $item->ID;
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
$class_names = ' class="' . esc_attr( $class_names ) . '"';
$id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
$id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';
$output .= $indent . '<li' . $id . $value . $class_names . $li_attributes . '>';
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
$attributes .= ($args->has_children) ? ' class="dropdown-toggle" data-toggle="dropdown"' : '';
$item_output = $args->before;
$item_output .= '<a'. $attributes .'>';
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
$item_output .= ($args->has_children) ? ' <b class="caret"></b></a>' : '</a>';
$item_output .= $args->after;
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}
function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) {
if ( !$element )
return;
$id_field = $this->db_fields['id'];
//display this element
if ( is_array( $args[0] ) )
$args[0]['has_children'] = ! empty( $children_elements[$element->$id_field] );
else if ( is_object( $args[0] ) )
$args[0]->has_children = ! empty( $children_elements[$element->$id_field] );
$cb_args = array_merge( array(&$output, $element, $depth), $args);
call_user_func_array(array(&$this, 'start_el'), $cb_args);
$id = $element->$id_field;
// descend only when the depth is right and there are childrens for this element
if ( ($max_depth == 0 || $max_depth > $depth+1 ) && isset( $children_elements[$id]) ) {
foreach( $children_elements[ $id ] as $child ){
if ( !isset($newlevel) ) {
$newlevel = true;
//start the child delimiter
$cb_args = array_merge( array(&$output, $depth), $args);
call_user_func_array(array(&$this, 'start_lvl'), $cb_args);
}
$this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output );
}
unset( $children_elements[ $id ] );
}
if ( isset($newlevel) && $newlevel ){
//end the child delimiter
$cb_args = array_merge( array(&$output, $depth), $args);
call_user_func_array(array(&$this, 'end_lvl'), $cb_args);
}
//end this element
$cb_args = array_merge( array(&$output, $element, $depth), $args);
call_user_func_array(array(&$this, 'end_el'), $cb_args);
}
}
}
endif;
Save the boostrap-walker.php file
Open functions.php
At the bottom of this file, you will want to write the code to include our new bootstrap-walker.php file. It should look like the following:
<?php
/**
* The header for our theme.
*
* Displays all of the <head> section and everything up till <div id="content">
*
* #package bootstrapwp
*/
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="page" class="hfeed site">
<header id="masthead" class="site-header" role="banner">
<nav role="navigation">
<div class="navbar navbar-static-top navbar-default">
<div class="container">
<!-- .navbar-toggle is used as the toggle for collapsed navbar content -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<?php bloginfo( 'url' ) ?>/" title="<?php bloginfo( 'name' ) ?>" rel="homepage"><?php bloginfo( 'name' ) ?></a>
</div>
<div class="navbar-collapse collapse navbar-responsive-collapse">
<?php
$args = array(
'theme_location' => 'primary',
'depth' => 2,
'container' => false,
'menu_class' => 'nav navbar-nav navbar-right',
'walker' => new Bootstrap_Walker_Nav_Menu()
);
if (has_nav_menu('primary')) {
wp_nav_menu($args);
}
?>
</div>
</div>
</div>
</nav>
</header><!-- #masthead -->
Note: I also removed the “skip to content” link from this code. I go over this in the next video tutorial.
Save the header.php file
Now that we have all the code in place, we can create a new Menu from the WordPress Dashboard. Login to the backend of your WordPress site (wp-admin) and go to Appearance -> Menu
Create a new menu, select and add a few pages to the menu, and assign it to the Primary Menu theme location.
Reload the front-end of your WordPress and play with your awesome Bootstrap menu!
If you want to learn more about the Walker Class you can read more about it http://codex.wordpress.org/Class_Reference/Walker

I am having a tough time making a title appear for my body

I am trying to make a title appear on the body of this page. Well for some reason the title doesn't show up when I use the center tag and I am can't figure out why. Can someone tell me what I is wrong with my center tag?
<!DOCTYPE HTML>
<html>
<head>
<title><?php echo'giggity'?></title>
</head>
<body>
<?php
$Title="The Title of my page";
?>
<center><?php echo $Title;?></center>
<?php
$con = mysqli_connect('localhost', 'username', 'password','Employees');
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// $db = mysqli_select_db($con,'Employees');
$sql = "select * from Employ";
$query = mysqli_query($con,$sql);
echo "<table border ='1' style='height:90%;width:90%; position: absolute; top: 0; bottom: 0; left: 0; right: 0;border:1px solid' BGCOLOR='00FF00'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Meetings_Today</th>
<th>Sales</th>
<th>Comments</th>
</tr>";
//now read and display the entire row of a table one by one looping through it.
//to loop we are using While condition here
while( $row = mysqli_fetch_array($query) )
{
echo "<tr><td>". $row['Firstname']. "</td>";
echo "<td>". $row['Lastname']. "</td>";
echo "<td>". $row['Meetings']. "</td>";
echo "<td>". $row['Sales']. "</td>";
echo "<td>". $row['Comments']. "</td></tr>";
}
echo "</table>";
mysqli_close($con);
?>
</body>
</html>
The following code works fine for me (see http://www.floris.us/SO/title.php)
<!DOCTYPE HTML>
<html>
<head>
<title><?php echo'giggity'?></title>
</head>
<body>
<?php
$Title="The Title of my page";
?>
<center><?php echo $Title;?></center>
</body>
</html>
This is exactly the code you pasted (same spaces etc), but closing the body and html tags after printing the title.
I recommend you start from this, then add code "until it breaks".
OK - I added code myself. The way you lay out your table, it goes all the way to the top of the page, and therefore "sits on top" of the title. Change the top to something that leaves space for the title - or put the title inside the table…
Possible solution:
echo "<table border ='1' style='height:90%;width:90%; position: absolute; top: 50; bottom: 0; left: 0; right: 0;border:1px solid' BGCOLOR='00FF00'>
I put this to work in http://www.floris.us/SO/title2.php
Source code:
<!DOCTYPE HTML>
<html>
<head>
<title><?php echo'giggity'?></title>
</head>
<body>
<?php
$Title="The Title of my page";
?>
<center><?php echo $Title;?></center>
<?php
echo "<table border ='1' style='height:90%;width:90%; position: absolute; top: 50; bottom: 0; left: 0; right: 0;border:1px solid' BGCOLOR='00FF00'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Meetings_Today</th>
<th>Sales</th>
<th>Comments</th>
</tr>";
// replace db access with a single line of text:
echo "<tr><td>". "John". "</td>";
echo "<td>". "Smith". "</td>";
echo "<td>". "Pocahontas". "</td>";
echo "<td>". "Firewater". "</td>";
echo "<td>". "English". "</td></tr>";
echo "</table>";
?>
</body>
</html>

Boxes are tripping if I insert text in them

* RESOLVED BY INTENSE RESEARCHING *
[DOWNLOAD CODE, NO COPYRIGHT =)] .rar file ( always scan before opening .rar - F4LLCON
Problem is that without text the boxes are placed 2 on each row, but with text the boxes
appear under each other with spacing. To get the text in the boxes I used <style> in <head>.
How can I FIX this annoying problem?
IMAGE:
Without the p and h3, both echo text will appear under the box and not in the box
Code:
<style>
p {
position:relative;
top:-240px;
left:180px;
}
h3 {
position:relative;
top:-270px;
left:30px;
}
</style>
and
<div class="offers">
<div class="content_box">
<?php
while($products = mysql_fetch_array($result)) {
echo '<img src="includes/images/content_box.png" border=0/>';
// echo "<h3>" . $products['products'] . "</h3>";
// echo "<p>" . $products['description'] . "</p>";
}
?>
</div>
</div>
RESOLVED BY DOING:
<STYLE TYPE="text/css">
#title{color:red; padding-bottom: 240px; padding-left: 25px;}
#desc{color:blue; padding-bottom: 135px; padding-left: 5px;}
</STYLE>
</head>
and
<div>
<?php while($products = mysql_fetch_array($result)) {?>
<table align="left" background="includes/images/box.gif" width="473" height="285">
<tr>
<td width="35%" height="100%" id="title">
<?php echo $products['products'] . "&nbsp"; ?>
</td>
<td width="70%" height="100%" id="desc">
<?php echo $products['description'];?>
</td>
</tr>
</table>
<?php
}
?>
</div>
</body>
This might be easy for some, but I'm new to this.
Now working correctly.
Thank you for giving me directions and Thank you Google and Stackoverflow for so much help =)
I am asuming that content_box.png is the background for the box right?
instead of including it in a create it in the background of a div with a class like this
CSS:
.product_box {
bacground:url(includes/images/content_box.png);
width:xxxpx; /* the width of conrent_box.png */
height:xxxpx; /* the height of conrent_box.png */
position:relative;
float:left;
}
php:
<?php
while($products = mysql_fetch_array($result)) {
echo '<div class="product_box">';
// echo '<img src="includes/images/content_box.png" border=0/>';
echo "<h3>" . $products['products'] . "</h3>";
echo "<p>" . $products['description'] . "</p>";
echo '</div>';
}
?>
Hope it helps!