Position issues after converting a page from html to php - php

I'm having a issue when converting my .html page into .php when I do so, one of the elements jumps from it's position.
(Note: the following links to the images will not work if you do not delete one of the extra dots before the png extension I'm sorry that I have to do it this way it's just that I'm new here in the site and I still have a low reputation to post pictures, I really need help)
This is how I want it to be and how it displays in the .html page
But this is how it turns out after converting to .php
Thanks in advance!
<div class="top-headlines">
<ul class="th-content">
<a href="#"><li><img src="publicidade/002.jpg" /><h1> Getting
freelance jobs is very common</h1> amongst designers and programmers. It gives you the
freedom to use your time the way you wish to and also to work on projects that you
like. But, the problem often arises in finding ample freelance jobs to sustain yourself.
Not to worry though. Here’s a list of 10 different websites where programmers and designers
can find freelance jobs. So, if you have been looking for such jobs, take a look.</li></a>
<a href="#"><li id="top-left"><img src="publicidade/004.jpg" />
<h1>Getting freelance jobs is very common</h1> amongst designers
and programmers. It gives you the freedom to use your time the way you wish to and
also to work on projects that you like. But, the problem often arises in finding ample
freelance jobs to sustain yourself. Not to worry though. </li></a>
</ul>
</div>
.top-headlines h1{
margin-bottom: 10px;
font-family: arial, tahoma, sans-serif;
font-size: 1.5em;
font-style: normal;
font-variant: normal;
font-weight: 300;
line-height: normal;
letter-spacing: 0.01em;
}
.top-headlines{
float:left;
clear:both;
height: 100%;
min-height: 320px;
max-height: 420px;
text-align:justify;
font-family: arial, sans-serif;
font-size: 16px;
}
.top-headlines a{
text-decoration:none;
text-align:justify;
font-family: arial, sans-serif;
font-size: 18px;
color: black;
font-size: 1em;
font-weight: 200;
line-height: 1.5em;
}
.top-headlines a:hover{
color: #666666;
}
.top-headlines img{
width: 275px;
height: 170px;
}
.th-content li{
float:left;
width:500px;
height:315px;
margin-right: 10px;
border-right: 1px #999999 solid;
padding-right: 10px;
list-style:none;
}
.th-content img{
float:left;
margin-right: 5px;
margin-bottom: 5px;
}
#top-left{
width:450px;
clear:right;
border:none;
}

Make .top-headlines have display: inline-block.

Try adding these properties:
.top-headlines {
position:relative;
}
.th-content li{
width:50%;
box-sizing:border-box;
-moz-box-sizing:border-box;
}
Codepen for illustration. Images don't load but it shows the positioning:
http://codepen.io/jwktje/pen/kFJpy

Related

How do I style a WordPress PHP link?

<div class="past-page"><?php previous_posts_link( '« Previous Page' ); ?></div>
Hello! I'm having a bit of troubles trying to solve the styling of a pagination button. I tried styling the past-page div, but that made a white box show up when no link was there... which was not the result I wanted.
So, I'm wondering if I can somehow add styling in the php tag here?
The style I want to add is
font-size: 10pt;
text-transform: uppercase;
font-weight: bold;
background: #fff;
padding: 10px;
use :not(:empty) to add style to a div that is 'not empty'; otherwise, when it is blank, it reverts back to the default CSS:
<style>
.past-page:not(:empty) {
font-size: 10pt;
text-transform: uppercase;
font-weight: bold;
background: #fff;
padding: 10px;
}
</style>
Alternatively, you could apply the style always unless empty then make it invisible:
<style>
.past-page {
font-size: 10pt;
text-transform: uppercase;
font-weight: bold;
background: #fff;
padding: 10px;
}
.past-page:empty {
display: none !important;
}
</style>

Button Grid spacing

I have some problems with a button arrangement where I have several buttons forming a grid.
The problem I am encountering is, that as soon as there is more than one line of text inside the button it gets shifted downwards.
I think you see what the problem is.
<button class="boxed" dummy="0" name="x" type="submit" value="x">
SEGEBERGER ZTG.DO
</button>
corresponding CSS
button {
background:#fff;
border: 1px solid #c1c1c1;
padding-left:11px;
padding-right:11px;
height:29px;
margin-top: 5px;
white-space: normal;
}
.boxed {
margin-left:1px;
padding-top:10px;
padding-left:10px;
width:100%;
max-width:150px;
height:150px;
font-size: 10pt;
word-break: break-all;
}
I looked around but did not find anything that fixed it.
https://jsfiddle.net/k1vvsx2h/
Hope someone has a hint on how to fix this.
Have a good one :)
Adding a float:left will fix this issue.
.boxed {
float: left;
margin-left: 1px;
padding-top: 10px;
padding-left: 10px;
width: 100%;
max-width: 150px;
height: 150px;
margin-right: 5px;
font-size: 10pt;
word-break: break-all;
}
button {
background: #fff;
border: 1px solid #c1c1c1;
padding-left: 11px;
padding-right: 11px;
height: 29px;
margin-top: 5px;
white-space: normal;
}
Here also a jsFiddle for you: https://jsfiddle.net/hb8ydyba/1/. Make sure you're using a clearfix with this solution.
If you're looking for a more flexible solution maybe a CSS Framework like Bootstrap or UIKit and their Gridsystems will work out well for you.

Only show text on image when you hover - wordpress theme

I'm using this WP theme and I'm struggeling to adjust the code so that the Title and Description in the content boxes only show on hover (at the moment they're always displayed and hover just makes the image go darker).
Here are the codes in question (as far as I can tell):
.home_featured_post_last { margin-right: 0; }
.home_featured_post_hover { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: block; text-decoration: none; border-radius: 5px; }
.home_featured_post_hover:hover { background: url('images/trans-back.png') repeat; text-decoration: none; border-radius: 5px; }
.home_featured_post_tbl { display: table; width: 100%; height: 100%; }
.home_featured_post_tbl_cell { display: block; text-align: center; vertical-align: middle; color: #fff; text-shadow: 1px 1px #000; font-size: 14px; font-family: Arial, Helvetica, sans-serif; color: #fff; letter-spacing: 1.5px; font-weight: 400; }
.home_featured_post_tbl_cell h3 { text-shadow: 1px 1px #000; font-size: 19px; font-family: Arial, Helvetica, sans-serif; color: #fff; letter-spacing: 1.5px; font-weight: 700; }
<a class="home_featured_post_hover" href="<?php the_permalink(); ?>">
<div class="home_featured_post_tbl">
<div class="home_featured_post_tbl_cell">
<h3><?php the_title(); ?></h3>
<p><?php echo ds_get_excerpt('40'); ?></p>
</div><!--//home_featured_post_tbl_cell-->
</div><!--//home_featured_post_tbl-->
</a><!--//home_featured_post_hover-->
As suggested in some other posts, I've tried adding visibility: hidden; and visibility: visbile; to the CSS in various different combinations but either it just hides the text completely or it doesn't work at all. Does this have to do with how the PHP code is formated? Any thoughts on how to do this?
Sorry if this is really obvious - I can't work it out.
Try adding these CSS lines... if you want a smoother effect, you can add the css transition property!
a.home_featured_post_hover .home_featured_post_tbl_cell { opacity:0; }
a.home_featured_post_hover:hover .home_featured_post_tbl_cell { opacity:1; }
What this does is basically make the title/desc div transparent, then show it when the mouse is over the link.

PHP: str_replace doesn't work (Other answers on SO did not help)

I wrote the following SSCCE to demonstrate that I have a string (of some HTML), and I am using simple_html_dom parser to find out the div with a particular value of the class attribute. This works fine. But I need to remove this div from the parent string. So I am using str_replace, but it doesn't seem to work. Please tell me why and what is the solution.
I checked the solutions to questions addressing similar problems but they did not apply or work on my problem. I also tried to use str_replace_first from this question's answer by Bas. But it does not work either.
You can see in the screenshot that it just prints the entire $haystack after printing --------.
$haystack = '<div class="region-content" style="margin-right:100px; margin-left:100px;">
<div role="main"><span id="maincontent"></span><div class="que description informationitem notyetanswered" id="q6"><h4 class="accesshide">Question text</h4><input type="hidden" name="q3:6_:sequencecheck" value="1" /><div class="qtext"><p style="font-family: HelveticaNeueW01-55Roma, Helvetica, Arial, san-serif; margin: 0px 0px 20px; padding: 0px; color: #464646; font-size: 14.4444446563721px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">Schools expect textbooks to be a valuable source of information for students. My research suggests, however, that textbooks that address the place of Native Americans within the history of the United States distort history to suit a particular cultural value system. In some textbooks, for example, settlers are pictured as more humane, complex, skillful, and wise than Native Americans. In essence, textbooks stereotype and depreciate the numerous Native American cultures while reinforcing the attitude that the European conquest of the New World denotes the superiority of European cultures. Although textbooks evaluate Native American architecture, political systems, and homemaking, I contend that they do it from an ethnocentric, European perspective without recognizing that other perspectives are possible. </p>
<p style="font-family: HelveticaNeueW01-55Roma, Helvetica, Arial, san-serif; margin: 0px 0px 20px; padding: 0px; color: #464646; font-size: 14.4444446563721px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">One argument against my contention asserts that, by nature, textbooks are culturally biased and that I am simply underestimating children\'s ability to see through these biases. Some researchers even claim that by the time students are in high school, they know they cannot take textbooks literally. Yet substantial evidence exists to the contrary. Two researchers, for example, have conducted studies that suggest that children\'s attitudes about particular cultures are strongly influenced by the textbooks used in schools. Given this, an ongoing, careful review of how school textbooks depict Native Americans is certainly warranted.</p></div><div class="im-controls"><input type="hidden" name="q3:6_-seen" value="1" /></div></div>
<div class="que multichoice deferredfeedback notyetanswered" id="q7"><div class="qtext"><p><span style="color: #464646; font-family: HelveticaNeueW01-55Roma, Helvetica, Arial, san-serif; font-size: 14.4444446563721px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">Which of the following would most logically be the topic of the paragraph immediately following the passage?</span></p></div><div class="ablock"><div class="prompt">Select one:</div><div class="answer"><div class="r0"><input type="radio" name="q3:7_answer" value="0" id="q3:7_answer0" /><label for="q3:7_answer0">a. <span style="color: #464646; font-family: HelveticaNeueW01-55Roma, Helvetica, Arial, san-serif; font-size: 14.4444446563721px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.5px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">the contributions of European immigrants to the development of the United States</span></label> </div>
<div class="r1"><input type="radio" name="q3:7_answer" value="1" id="q3:7_answer1" /><label for="q3:7_answer1">b. <span style="color: #464646; font-family: HelveticaNeueW01-55Roma, Helvetica, Arial, san-serif; font-size: 14.4444446563721px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.5px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;"><span class="Apple-converted-space"> </span>the centrality of the teacher\'s role in United States history courses</span></label> </div>
<div class="r0"><input type="radio" name="q3:7_answer" value="2" id="q3:7_answer2" /><label for="q3:7_answer2">c. <span style="color: #464646; font-family: HelveticaNeueW01-55Roma, Helvetica, Arial, san-serif; font-size: 14.4444446563721px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.5px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">nontraditional methods of teaching United States history</span></label> </div>
<div class="r1"><input type="radio" name="q3:7_answer" value="3" id="q3:7_answer3" /><label for="q3:7_answer3">d. <span style="color: #464646; font-family: HelveticaNeueW01-55Roma, Helvetica, Arial, san-serif; font-size: 14.4444446563721px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.5px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">specific ways to evaluate the biases of United States history textbooks <br /></span></label> </div>
<div class="r0"><input type="radio" name="q3:7_answer" value="4" id="q3:7_answer4" /><label for="q3:7_answer4">e. <span style="color: #464646; font-family: HelveticaNeueW01-55Roma, Helvetica, Arial, san-serif; font-size: 14.4444446563721px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.5px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">ways in which parents influence children\'s political attitudes <br /></span></label> </div>
</div></div></div>';
require('C:/xampp/htdocs/simple_html_dom.php');
$html = str_get_html($haystack);
foreach($html->find('div[class=que description informationitem notyetanswered]') as $h) {
$reading_passage_outertext = $h->outertext;
}
$hay = str_replace($reading_passage_outertext, "", $haystack);
echo $reading_passage_outertext;
echo '---------------------------------------------------------------------------------------------------------------';
echo $hay;
I guess outertext is returning an interpretation of parsed html. So it probably removes excess spaces, and may jumble the order of attributes. In other words you're getting a different string out than what str_get_html took in. You may want to just remove the div using the parser instead of str_replace
What I can see on your example is, that
$hay = str_replace($reading_passage_outertext, "", $haystack);
echo $reading_passage_outertext;
is outside of the foreach.
So $reading_passage_outertext only contains the last entry and str_replace does not really work.
I'm also not realy shure why you run through the str_get_html.
It doesn't make sense and costs quite some performance.
str_replace also accepts arrays as pattern and replacement values.
Try using str_replace only.

How to view hidden <span> by selecting a link earlier in document?

I don't even know if I'm doing this correctly, but I thought I'd ask to get a better opinion. Basically what I've done is this: created an information/navigation bar that expands depending on tab clicked by the user. What I'm trying to add is the functionality to expand a certain tab and be forwarded to it (like what this link would do: <a href="#contactus">) based on a link earlier on the same page. I can't seem to do it. The tab that should be opened is contained within a <ul><li> list and is hidden. I'll include the code:
<div id="tab1">
<ul class="tablinks">
<li><span>Check-Out</span></li>
<li><a onClick="show('tab2')">Payment</a></li>
</ul>
<table>
<tr>
<td><img alt=Check-Out src="http://link.com/images/checkouticon.gif" width=48px height=45></td>
<td>
<p style="font-family: arial,helvetica,sans-serif; font-size: 12px; padding-top: 5px; padding-bottom: 5px; padding-left: 5px">information</p>
</td>
</tr>
</table>
<div class="tabbase"></div>
</div>
<!-- tab 2 -->
<div id="tab2">
<ul class="tablinks">
<li><a onClick="show('tab1')">Check-Out</a></li>
<li><span>Payment</span></li>
</ul>
<table>
<tr>
<td vAlign=top align=left><img alt=Check-Out src="http://link.com/images/paypalicon.gif" width=48px height=45></td>
<td>
<p style="font-family: arial,helvetica,sans-serif; font-size: 12px; padding-top: 5px; padding-bottom: 5px; padding-left: 5px">information</p>
</td>
</tr>
</table>
<div class="tabbase"></div>
</div>
This is the CSS that affects it:
#tab1, #tab2, #tab3, #tab4, #tab5, #tab6, #tab7 { font-family: trebuchet ms, Helvetica, sans-serif; height:550px;}
#tab1, #tab2, #tab3, #tab4, #tab5, #tab6, #tab7 {
width: 750px;
font-family: "trebuchet ms", tahoma, verdana, sans-serif;
font-size: 11px;
}
#tab2, #tab3, #tab4, #tab5, #tab6, #tab7 {
display: none;
}
ul.tablinks {
width: 600px;
margin: 20px 0px 0px 0px;
padding: 0px;
list-style: none;
height: 23px;
display: block;
cursor: pointer;
border-bottom: 0px solid #fff;
}
ul.tablinks li {
display: inline;
float: left;
margin: 0px 4px 0px 0px;
padding: 0px;
}
ul.tablinks li a, ul.tablinks li a:visited {
display: block;
width: 79px;
height: 23px;
line-height: 23px;
text-align: center;
text-decoration: none;
font-weight: normal;
font-size: 11px;
background: url(http://link.com/images/tabout3.gif);
color: #ffffff;
}
ul.tablinks li span {
display: block;
width: 79px;
height: 23px;
line-height: 23px;
text-align: center;
text-decoration:underline;
font-weight: normal;
font-size: 11px;
}
ul.tablinks li a:hover,
ul.tablinks li a.hover {
background: url(http://link.com/images/tabover.gif);
color: #000;
}
ul.tablinks li a:active{
text-decoration:underline;
}
div.tabbase {
display: block;
height: 3px;
line-height: 8px;
font-size: 0px;
}
div.tabbase {
background: url(http://link.com/images/boxbase3.gif);
}
And last but not least this is the code that is within a .php external file that affects the hidden aspect of the tabs:
function show(id)
{
checkseo()
if (err == "1"){return;}
hide()
if(ie5 || ns6){
//document.getElementById(id).style.display = "inline";
document.getElementById(id).style.display = "block";
}
}
function hide(){
if(ie5 || ns6){
document.getElementById('tab1').style.display = "none";
document.getElementById('tab2').style.display = "none";
document.getElementById('tab3').style.display = "none";
document.getElementById('tab4').style.display = "none";
document.getElementById('tab5').style.display = "none";
document.getElementById('tab6').style.display = "none";
document.getElementById('tab7').style.display = "none";
}
}
So the idea is to be able to insert a link earlier in the document to open the "Payment" tab. I tried something like this: Payment Information and changed the tags for the list to: <li><span name="payments">Payments</span></li>. This didn't work unless I had already clicked on the "Payments" tab and opened it and then clicked on the link. Then my screen would scroll down and focus on that area. Is there a way to have the screen scroll down and view the <span> without having to 'open' it first?
Thanks for all your help in advance. And I should note, that while I do have some ability with HTML, Javascript, and PHP, I'm still learning and don't know all of the best ways of doing things.
The best (and easiest) way to code this is to use a JS framework like jQuery. It'll help tremendously in normalizing the browser differences.
But if that's not an option, let's try to fix the existing code. Payment Information will jump to an element with the id="payments", not name. Once you fix that, add an onClick="show('tab2')" to that <a>.
In the show function, what is the point of this code if(ie5 || ns6)? This is basically saying, if it's IE5 or Netscape6, then show the element (assuming the variable ie5 and ns6 are set properly somewhere of course). Try removing this, I don't think you need it.

Categories