关于SO的第一个问题!
我试图"像素完美"水平对齐两行文本,每行具有不同的字体大小.
<style type="text/css">
* { font-family: sans-serif;}
div { float: left;}
h1 { font-size: 150px; margin-bottom:-30px; }
</style>
<div>
<h1> B </h1>
<h6> B-L.align </h6>
</div>
<div>
<h1> L </h1>
<h6> L.align </h6>
</div>
Run Code Online (Sandbox Code Playgroud)
这里示例:http://jsfiddle.net/jgYBD/1/
如果您查看示例,您会注意到较大的字体有更多"?padding?" 比较小的字体.使它们与几个像素不对齐.
我正在寻找一种方法或公式来完美地左对齐它们,而不使用左边缘的试验和错误!
所有的想法都表示赞赏,谢谢.
我刚刚开始学习Haskell,并且很难理解Haskell程序的"流程".
例如在Python中,我可以编写一个脚本,将其加载到解释器并查看结果:
def cube(x):
return x*x*x
print cube(1)
print cube(2)
print cube(cube(5))
# etc...
Run Code Online (Sandbox Code Playgroud)
在Haskell中,我可以这样做:
cube x = x*x*x
main = print (cube 5)
Run Code Online (Sandbox Code Playgroud)
加载它,runhaskell它将打印125.
或者我可以使用ghci并手动输入我想要测试的所有功能
但我想要的是使用我的文本编辑器,编写几个函数,一些测试,并让Haskell打印出一些结果:
-- Compile this part
cube x = x*x*x
-- evaluate this part:
cube 1
cube 2
cube (cube 3)
--etc..
Run Code Online (Sandbox Code Playgroud)
这样的事情可能吗?
我试图了解如何创建自定义打印功能.(使用python 2.7)
import sys
class CustomPrint():
def __init__(self):
self.old_stdout=sys.stdout #save stdout
def write(self, text):
sys.stdout = self.old_stdout #restore normal stdout and print
print 'custom Print--->' + text
sys.stdout= self # make stdout use CustomPrint on next 'print'
# this is the line that trigers the problem
# how to avoid this??
myPrint = CustomPrint()
sys.stdout = myPrint
print 'why you make 2 lines??...'
Run Code Online (Sandbox Code Playgroud)
上面的代码将此打印到控制台:
>>>
custom Print--->why you make 2 lines??...
custom Print--->
>>>
Run Code Online (Sandbox Code Playgroud)
我想只打印一行:
>>>
1custom Print--->why you make …Run Code Online (Sandbox Code Playgroud)