Created a blog using Jekyll and git hub pages. I need to indent to align a list of expenses. I found a way how, but I would like to insert that into a function.
Example:
Sum of Contractor expenses - $6,800
Heating and Air - $5,100
Fridge and Stove - $1,100
Hardware store purchases - $5,000
Miscellaneous - $2,000
I would like all of the amounts to line up.
According to this SO question, I can use to create a space. However, I need to insert a lot of these to obtain what I want.
Another suggestion is Tab+Space but this doesn't seem to work in the middle of the text.
From the same post, I tried using Alt+0+1+6+0 and that seems to work.
The expected results would look like this.
Sum of Contractor expenses - TAB;$6,800
Heating and Air - TAB;(5)$5,100
As the answer to that SO question states:
There's no way to do that in markdown's native features. However markdown allows inline HTML...
There are a couple of ways you could do this. You could use a <table> element, where the HTML looks like this:
<table>
<tr><td>Sum of Contractor expenses</td><td>$6,800</td></tr>
<tr><td>Heating and Air</td><td>$5,100</td></tr>
<tr><td>Fridge and Stove</td><td>$1,100</td></tr>
<tr><td>Hardware store purchases</td><td>$5,000</td></tr>
<tr><td>Miscellaneous</td><td>$2,000</td></tr>
</table>
Or, you could use class names and CSS, where the HTML looks like this:
<div>
<span class="description">Sum of Contractor expenses</span>
<span class="cost">$6,800</span>
</div>
<div>
<span class="description">Heating and Air</span>
<span class="cost">$5,100</span>
</div>
<div>
<span class="description">Fridge and Stove</span>
<span class="cost">$1,100</span>
</div>
<div>
<span class="description">Hardware store purchases</span>
<span class="cost">$5,000</span>
</div>
<div>
<span class="description">Miscellaneous</span>
<span class="cost">$2,000</span>
</div>
And, the CSS looks like this:
.description { width: 100px }
.cost { width: 30px; text-align: right; }
Note 1: You'll need to play with the widths to get things aligned the way you want.
Note 2: You could also apply class names and CSS to the <td> tags in the <table>.
Related
I'm using XPATH to extract information from a website which generates data of the following structure:
<span class="classA">
<span class="classA1">aaa:</span> <strong>ccc</strong><br>
<span class="classA1">ddd:</span> eee<br>
<span class="classA1">fff:</span> <b>ggg gg </b><br>
...
<span class="classA1">hhh:</span>
jjj,
...
lll<br>
<br>
</span>
<span class="classB">mmm <b>nnn</b> ...
<br><br>
</span>
<span class="classA">
<span class="classA1">ooo:</span> ppp<br>
<span class="classA1">qqq:</span> rrr<br>
...
</span>
A few things to note first:
the exact number of <span class="classA1"> tags varies
the <a> tags after <span class="classA1">hhh:<span> varies
To extract what follows the individual classA1 spans, I use this XPATH definition:
//span[contains(text(),'aaa:')]//following::text()[1]
//span[contains(text(),'ddd:')]//following::text()[1]
//span[contains(text(),'fff:')]//following::text()[1]
...
And so on.
Trying to extract the text after <span class="classA1">hhh:<span>, that is, either the plain text "jjj" and "lll" or the whole html part (i.e. "jjj,...lll"), I keep running into problems.
Since, as I mention above, the number of tags there may vary greatly and is unpredictable, I cannot simply identify them by index number. And if I use the following, I also get everything that follows including the following classB span, which I definitely don't need or want.
//span[contains(text(),'hhh:')]//following::text()
Can you, please, suggest an XPATH solution?
Many thanks!
Since your source html shows indention not corresponding the parent/child relation, it is not totally clear but maybe this helps:
//span[contains(.,'mmm')]/preceding::span[contains(.,'hhh:')][1]/following-sibling::a[not(span[contains(.,'mmm')])]
If I understand correctly what are you asking for, this should give you all the a elements coming after the <span class="classA1">hhh:</span> element:
//span[#class='classA1' and text()='hhh']/following-sibling::a
Now you can iterate over the list or resulting a elements and extract their texts.
Alternatively you can get their texts directly with this:
//span[#class='classA1' and text()='hhh']/following-sibling::a/text()
I'm learning bootstrap currently (by the way it is AMAZING!) and i have a question. I have a 'h3' tag like so...
<h3 class="pull-right">CALL 555-123-4567</h3>
what i'd like to do to style this tag is make the "call" part one color, and the phone number another color.
I know how to do it with css, but does bootstrap have anything to do with this? Do I need to make another class for the 'call' word seperate from the phone number?
For instance. . .
<h3 class="pull-right"><h3 class="#">CALL</h3><h3 class="#">555-123-456</h3>
OR would it be more a ID like this?
<div id="container"> <!--pull this right with bootstrap? would that even work? would the name need to be 'pull-right' and not container?-->
<h3 class="colorChange"> CALL <h3> <h3 class="newColorChange" 555-123-4567</h3>
</div>
Which is more proper? The original question of changing text color with bootstrap framework is my main concern.
You should never nest h3 inside a h3 tag. To style CALL and phone no. separately, all you need to is this:
<h3 class="pull-right">
<span class="call">CALL</span>
<span class="number">555-123-4567</span>
</h3>
Now can style CALL and Number separately.
I have a repeating partial view in an ASP.NET MVC 5 application that is showing up incorrectly in certain circumstances in Chrome. It's not happening in any other browser, and I'm at a loss to figure out what's going on.
My razor code is pretty straightforward -- just a foreach loop that calls #Html.Partial(). I'm going to skip it for now in the interest of saving space, but the HTML it produces looks like this:
<div id="dataDisplay">
<div id="dataRow39" class="list">
Edit
<span class="normal">AAA Test 1</span>
<span class="large">Test Description 1</span>
X
</div>
<div id="dataRow1" class="list">
Edit
<span class="normal">AHBA</span>
<span class="large">Arkansas Home Builders Association</span>
X
</div>
. . .
</div>
And the page itself looks like this:
When users click the "Edit" link, I use an AJAX call to replace a single div with a different partial view that has input elements for data-entry. That div also has a cancel button that triggers another AJAX call back to the original partial view. That produces nearly identical HTML, but one element gets positioned wrong.
<div id="dataDisplay">
<div id="dataRow39" class="list">
Edit
<span class="normal" style="">AAA Test 1</span>
<span class="large" style="">Test Description 1</span>
X
</div>
<div id="dataRow1" class="list">
Edit
<span class="normal">AHBA</span>
<span class="large">Arkansas Home Builders Association</span>
X
</div>
. . .
</div>
The only difference I can see is those empty style tags. They don't appear in the console when I debug my AJAX, and they don't appear in other browsers. But if I manually go in and remove them, it doesn't seem to fix the layout problem.
I realize I've left out a lot of details. I'm trying to keep this from being really excessively long. I can provide any of the missing details if needed. Does anybody have any idea what could be going wrong?
UPDATE: As I'm playing around with this a bit, I have a feeling it has something to do with the float:right on the .delete-button class. Here's the CSS for that class:
.delete-button {
float: right;
font-size: .9em;
text-align: right;
padding: 0 3px;
margin: auto 0;
color: #888;
}
I am working on a system that generates content based on a user's input.
User Input:
First Name: Chris
Current State: helpless
Generated Content:
This site is about Chris and he is currently helpless.
In order to let the user change the First Name or Current State later on, I need to associate the actual text in the page with the input names like so:
This site is about <span class="first-name">Chris</span> and he is currently
<span class="current-state">helpless</span>.
How can I do this a without using spans like in the example above? I can't seem to find an HTML tag suitable for this.
Edit: It is hard to explain why I can't use spans. I am unable to use spans for this because I am using spans as targets that denote editable areas in the page. Using spans for the above purpose as well ends up causing issues that are far too complicated to describe here.
Edit 2: (including code from comments)
The issue is that I am wrapping all text nodes that are inside of <p> tags with the spans that denote editable content. Now, if I put spans inside of any of those <p> tags (namely spans that denote user inputs) I end up with real bad results.
It ends up looking like this:
<p>
<span class="editable">This site is about</span>
<span class="first-name">Chris</span>
<span class="editable">and he is currently</span>
<span class="current-state">helpless</span>
<span class="editable">.</span>
</p>
Instead of this:
<p>
<span class="editable">This site is about Chris and he is currently helpless.</span>
</p>
I have always struggled designing css forms, I can never get the input and label side by side. Do you have any words of wisdom that may help me.
I usually use a 10px margin on the bottom but cannot get them aligned
My Common form:
Name:
Email:
Phone:
Message:
text area
I know I'm going to get backlash for this from people who think that the only possible way to do things is with pure CSS, divs, spans, etc. However, your form is tabular. You have a column of titles, and a column of input fields. In this case, because of the tabular layout, a valid solution could be tables.....GASP!
Tables are not valid for page layout...let me repeat that again, tables are not valid for layout. However, you've got an element of a page, you're not doing a full page layout. You can easily use <th> elements to style the labels for the inputs, which is quick and simple. Overall, the table (tabular) solution would be less verbose than many of the CSS layouts given, which from a pure HTML standpoint is a win. It will continue to work and layout properly even when the server gets backed up and can't load the external CSS document. To all those who believe that tables are never ok, let me remind you that this solution will validate with W3 100% of the time provided your table is properly structured. And it's far more cross browser compatible, with no box-model issues in the "crabby" legacy browers. Certainly continue to progressively enhance with CSS as is best practice.
Theory and practice, especially in the web world, are two entirely different things. In theory, all of us should be producing 100% HTML5/CSS3/Semantic/SEO Optimized...blah blah blah. In practice, theory only goes as far as the first customer complaint. Progressive enhancement is key to survival. When a webform breaks in a big corporate setting, money is lost and people get fired. For that reason, the International Bank I recently did work for had requirements that demanded all its webforms were tabular (assembled with tables) It's hard to argue with a portfolio of sites whose users generate the company hundreds of millions of $$$ annually.
<style>
ul.anyclassname{
padding:0;
}
ul.anyclassname li{
list-style-type:none;
clear:left;
}
ul.anyclassname li label{
width:300px;
float:left;
}
.inputs{
float:left;
}
</style>
<form>
<ul class="anyclassname">
<li>
<label>Name:</label>
<div div class="inputs"><input type="text"></div>
</li>
<li>
<label>Email:</label>
<div div class="inputs"><input type="text"></div>
</li>
<li>
<label>Phone:</label>
<div div class="inputs"><input type="text"></div>
</li>
</ul>
</form>
I usually do this:
<div>
<label for="txtname">Name:</label>
<input type="text" id="txtname" name="txtname"/>
</div>
<div>
<label for="txtEmail">Email:</label>
<input type="text" id="txtEmail" name="txtEmail"/>
</div>
<div>
<label for="txtPhone">Phone:</label>
<input type="text" id="txtPhone" name="txtPhone"/>
</div>
etc...
Then with my CSS:
label { width: 100px; display: inline-block; }
Something along those lines. Nothing fancy, but they are side-by-side and with the surrounding div you get a block level element to give you a line return after each pair.
I wrote a complete form in this answer: how can we make forms like this with css & html? . It has the html markups and the css classes you need to start.
The code is also in a fiddle here: http://jsfiddle.net/vSqR3/64/ (Now with the nice addition of the for attribute, thanks Kyle!)
You will find in that link not only how to put one markup next to the other, but how to set sizes and borders for each.
I strongly suggest you to play on the jsfiddle.net website. You'll be able to modify and test immediately all your changes.