I'm very new to coding, and I've created an image carousel on the front page of a local wordpress site. It's not displaying my images at all. Here's my PHP code:
///HOMEPAGE IMAGE CAROUSEL///
$sliderholder = '<div class="slider-holder" >';
$sliderholder .= '<span id="slider-image-1" ></span>';
$sliderholder .= '<span id="slider-image-2" ></span>';
$sliderholder .= '<span id="slider-image-3" ></span>';
$sliderholder .= '</div>';
$imageholder = '<div class="image-holder" >';
$imageholder .= '<img src="http://localhost/EllesSite/wp-content/uploads/2018/09/pexels-photo-1002638.jpeg" class="slider-image-1" />';
$imageholder .= '<img src="http://localhost/EllesSite/wp-content/uploads/2018/09/pexels-photo-905877.jpeg" class="slider-image-2" />';
$imageholder .= '<img src="http://localhost/EllesSite/wp-content/uploads/2018/09/pexels-photo-399161.jpeg" class="slider-image-3" />';
$imageholder .= '</div>';
$buttonholder = '<div class="button-holder" >';
$buttonholder .= '<a href="#slider-image-1" class="slider-change" ></a>';
$buttonholder .= '<a href="#slider-image-2" class="slider-change" ></a>';
$buttonholder .= '<a href="#slider-image-3" class="slider-change" ></a>';
$buttonholder .= '</div>';
add_action( 'loop_start', 'using_front_page_conditional_tag' );
function using_front_page_conditional_tag() {
if ( is_front_page() ) {
echo $sliderholder.$imageholder.$buttonholder;
}
}
?>
And my CSS:
/*IMAGE CAROUSEL*/
.slider-holder {
width: 100%;
height: 400px;
background-color: yellow;
margin-left: auto;
margin-right: auto;
margin-top: 0px;
text-align: center;
overflow: hidden;
}
.image-holder {
width: 2400px;
background-color: red;
height: 400px;
position: relative;
clear: both;
-webkit-transition: left 2s;
-moz-transition: left 2s;
-o-transition: left 2s;
}
.slider-image {
float: left;
margin: 0px;
padding: 0px;
position: relative;
}
#slider-image-1:target ~ .image-holder
{
left: 0px;
}
#slider-image-2:target ~ .image-holder
{
left: -800px;
}
#slider-image-3:target ~ .image-holder
{
left: -1600px;
}
.button-holder
{
position: relative;
top: -20px;
}
.slider-change
{
display: inline-block;
height: 10px;
width: 10px;
border-radius: 5px;
background-color: brown;
}
I was able to get the images to appear at one stage on the front page of the site, but they were not styled properly at all, it was really messy and gross on the page. I am now unable to see my images on the site at all. I have no idea where I'm going wrong, I thought it would be as simple as declaring each div as a variable, and then echoing the variables following the 'if' statement regarding the front page. I'm banging my head against the wall. Hoping someone can help. Thanks.
The easiest way to make content show only on the front page is to make a specific template for it.
In your theme (or better still, your CHILD theme - here's a good tutorial on that), copy page.php to a new file and name it front-page.php (if front-page.php already exists, just use that). This template is loaded only on the page that is set as your "homepage" in your Wordpress settings.
In your case here, you can simply add the standard html for your carousel wherever you want it to show in your front-page.php template.
Related
I am currently putting together a website, i have included a dynamic navigation bar developed purely in PHP with my basic ability.
However, using Chrome Dev Tool, i managed to obtain the style i wanted (on current page highlight the page name in white on navigation) , when including the style into my css file, the webpage would not show the style.
<?php
function outputHeader ($title){
echo '<!DOCTYPE html>';
echo '<html>';
echo '<head>';
echo '<title>' . $title . '</title>';
echo '<link rel="stylesheet" type="text/css" href="style.css">';
echo '</head>';
echo '<body>';
}
//Output Navigation
echo '<div id="banner">';
echo '<div id="nav">';
echo '<ul>';
function generateNav($pagename){
$page = array('index.php?' => 'Home', 'playerranking.php?' => 'Player Ranking', 'community.php?' => 'Community', 'register.php?' => 'Register','login.php' => 'Login',
);
foreach ($page as $link => $label){
if ($pagename == $label){
echo '<li><a class="current" href="' . $link . '">' . $label . '</li></a>';
}
else {
echo '<li>' . $label . '</li>';
}
}
echo '</ul>';
echo '</div>';
echo '</div>';
} >?
The css below
body {
background: #000;
margin: 0px;
}
#banner {
height: 109px;
width: 1295px;
background: #1d1d33;
margin-right: auto;
margin-left: auto;
}
#nav {
margin-right: 10%;
}
#nav ul {
overflow: visible;
text-decoration: none;
float: right;
}
#nav li {
display: inline;
font-family: Calibri, sans-serif;
font-size: 15px;
margin-top: 8%;
float: left;
padding-right: 30px;
list-style-type: none;
overflow: visible;
}
a#current {
color: #white;
}
#nav a {
text-decoration: none;
color: #8f8fa7;
}
From what i could see there was no two styles which were over-riding.
Help will be much appreciated
Thank you !
change
a#current {
color: #white;
}
to
#nav a.current {
color: white;
}
explanation:
# is the selector for id attributes, but you want to select the class "current". Class names are selected by .. Also, when using named colour values, don't prefix them with # - you only need the hash for hexadecimal rgb values.
In addition to all that, you have to add #nav in front of the rule so that it is more specific than the general rule #nav a. (You should also read up on CSS specificity in general)
`echo '<div class="col-sm-4">';
echo '<div class="product-image-wrapper">';
echo'<div class="single-products">';
echo'<div class="productinfo text-center">';
echo'<a href="product-detail.php id='.$row[9].'&item='.$_REQUEST['item'].'&product='.$row[2].'&pro=2">';
echo '<img src="image/thumb_images/'.$row['6'].'" />'; // image
$thumb='image/thumb_images/'.$row[6];
echo '<h6>Rs. ' .ROUND($row['SellingPrice']).'/-';
if($row['discount']>0){;
echo ' <span>MRP. ' .$row[4].' /-</span>';
}else{}
echo '</h6>';
echo'<h6>'.$row[2].'</h6>';
$name=$row[2];`
echo' </div>';
echo '</div>';
echo '</div>';
echo '</div>';
CSS
.single-products {
position: relative;
}
.new, .sale {
position: absolute;
top: 0;
right: 0;
}
.productinfo h6{
color:#fff;
}
.productinfo h5{
font-size: 70%;
text-decoration: line-through;
font-weight:bold;
color:#999;
}
.product-overlay h2{
margin-top:250px;
color: red;
}
.single-products h6{
color:#fff;
font-size: 90%;
vertical-align: top;
text-decoration: none;
line-height: 1;
}
.single-products span{
font-size:12px;
text-decoration: line-through;
font-weight:300;
color:#Fff;
}
.productinfo p{
font-family: 'Roboto', sans-serif;
font-size: 14px;
font-weight: 400;
color: #696763;
}
here i have write my bootstrap code and below i have attach my screenshot when i fixed size then it work fine but i want to fill up this gap by image... i have attach css also please read out the above code and give me answer related to problem..
please suggest me
With reference to Akhil try the following solution Kuldeep. Hope it works.
<?php
while($row = mysql_fetch_array($result)){
$product_count++ ;
echo '<div class="col-sm-4" style="text-overflow:ellipsis;">';
//put your code here
//put your code here
//put your code here
echo'</div>';
if($product_count % 3 == 0){
echo'<div style="clear: both;"></div>';
}
}
?>
kuldeep, either fix the height of the box and if there is more text you can use text-overflow: ellipsis; for showing more text is there. And one other option is You need to put a clear:both tag after each 3 boxes. You can make it in condition loop I think.
If I hover over the hyperlink, the tooltip shows up but not as it should. It shows up a few inches below the hyperlink. I got the code from a demo of the internet.
How do I get the tooltip right below the hyperlink?
Here is the PHP code I used:
if ($teller == 3) {
echo '<p><a href="#" class="tooltip">...<span>';
foreach ($bericht->datums as $date) {
echo date('d/m/Y', strtotime($date->datum)) . ' om ' . date('H:i', strtotime($date->beginUur)) . '<br />';
}
echo '</span></a></p>';
}
The code above generated this code in HTML:
<p>
<a href="#" class="tooltip">...
<span>
13/04/2013 om 13:49<br />
15/04/2013 om 12:50<br />
29/04/2013 om 16:00<br />
</span>
</a>
</p>
Here is the CSS that belongs to it:
a.tooltip span {
position:absolute;
z-index: 999;
white-space:nowrap;
bottom:9999px;
background:#81b0b0;
color:#e0e0e0;
padding:5px 12px;
line-height: 24px;
height: auto;
opacity: 0;
transition:opacity 0.5s ease-out;
}
a.tooltip span::before {
content: "";
display: block;
border-left: 6px solid #81b0b0;
border-top: 6px solid transparent;
position: absolute;
top: -6px;
left: 0px;
}
a.tooltip:link {
color:#FFF;
}
a.tooltip:visited {
color:#FFF;
}
a.tooltip:hover span {
opacity: 1;
bottom:-35px;
}
Can someone help me out please? Thanks! ;)
when you use
position:absolute;
it positions against the nearest container in the chain that has a position set; so if you don't have a position set on any of the elements that contain it, or its parents, it will position against the body.
try putting position absolute or relative on the containing p tag
I am building a comics website, but am having trouble aligning the images the way I want.
I'm going for this:
I'm trying to get the comics in a row like this (blue)
But all the images are coming out on top of each other:
I thought my CSS was correct...
*{
margin: 0;
padding: 0;
}
body {
background: gray;
text-align: center;
}
#wrapper {
width: 960px;
margin: 0 auto;
text-align: left;
background: white;
}
#comics {
/*top, right, bottom, left*/
margin: 50px 100px 50px 100px;
}
.comicBG {
position: absolute;
border: 1px dotted black;
background: #99FF33;
padding: 25px;
}
PHP:
echo '<td>';
echo '<span class="comicBG"><a href="./templates/viewcomic.php?id=' . $row['imgid'] . '">
<img src="' . $thumbpath.$row['imgthumb'] . '"/></a>' .
'<br />' . $row['imgtitle'] . '</span>';
echo '</td>';
Does anyone know the best way to position individual data elements (like the images)?
Should I be using a table, or a list?
Thanks!
I'd use an unordeder list. And you see all the images at the same place because you've set their position to absolute and you haven't set any coordinates.
You can remove position:absolute and the images should be in rows. And if you use an unorderer list, you can float the li's to the left.
Below I have included some HTML/CSS. The CSS looks fine in FF, but it is wrong in IE8. In IE8, the Home button appears on the line below the Balance and Turn values. It should appear on the same line. For comparison, you can view the page in both browsers (warning; potentially accesses FB profile) (This link leads to a Facebook app which will request your profile. You have to start a new game, choose a difficulty level, and then you will be taken to the game board. The code in question is at the bottom of the page). I hope someone can tell me how to fix the CSS for IE8. Thanks.
HTML CODE:
$html .= '<div id="info-panel">'."\n";
$html .= ' <div id="total-funds">Balance: €<span id="total-amount">'.$gamePlayerData['funds'].'</span>M</div>'."\n";
$html .= ' <div id="turn">Turn: '.$newTurn.'</div>'."\n";
$html .= ' <div id="home"><img src="' . $config->url->absolute->public . '/images/home_24x24.png" id="img-home" alt="Home" /></div>'."\n";
$html .= '</div>'."\n";
CSS CODE:
#info-panel {
width: 742px;
border: 3px solid gray;
background-color: #ddd;
color: red;
padding: 6px;
}
#total-funds {
display: inline;
font-size: 16px;
padding-right: 10px;
}
#turn {
display: inline;
font-size: 16px;
padding-right: 10px;
}
div#home {
display: inline;
float: right;
}
#img-home {
margin-top: -3px;
}
I found a fix. I changed the div#home rule to this:
div#home {
position: absolute;
right: 6px;
bottom: 4px;
}