使用:: before选择器添加空格

时间:2016-06-05 04:54:18

标签: css css-selectors

我试过这个但是没有用:

from tkinter import *
from tkinter import ttk
class Logic:
    def __init__(self,a,b,c,d):
        self.a = a
        self.b = b
        self.c = c
        self.d = d
    as_meter = dict(mm=0.001, cm=0.01, inch=0.0254,ft=0.3048, yd=0.9144, m=1.0,km=1000.0, mi=1609.344,)
    def calculate(self, *args):
        try:
            v = float(c)
        except ValueError:
            self.d.set('Invalid Input')
            return
        m = v * sign * self.as_meter [self.a]
        r = m/self.as_meter[self.b]
        answer = (self.d.set("{:.5g}".format(r)))
        return answer

class GUI:
    def __init__(self,root):
        self.notebook = ttk.Notebook(root)
        self.notebook.pack()

        self.length_frame = ttk.Frame(self.notebook)

        self.notebook.add(self.length_frame, text = 'Length')

        #Combobox
        self.measurements = StringVar()
        self.Combobox_Length_Left = ttk.Combobox(self.length_frame, textvariable = self.measurements, values = ('mm', 'cm', 'inch', 'ft', 'yd', 'm', 'km', 'mi'), width = 10,state=['readonly'])
        self.Combobox_Length_Left.current(5)
        self.Combobox_Length_Left.grid(row = 2, column = 0, padx = 5, pady = 5, sticky = E)

        self.measurements1 = StringVar()
        self.Combobox_Length_Right = ttk.Combobox(self.length_frame, textvariable = self.measurements1, value = ('mm', 'cm', 'inch', 'ft', 'yd', 'm', 'km', 'mi'), width = 10,state = ['readonly'])
        self.Combobox_Length_Right.current(5)
        self.Combobox_Length_Right.grid(row = 2, column = 2, padx = 5, pady = 5, sticky = E)

        #Labels
        self.Conversion = ttk.Label(self.length_frame, text = 'Convertion:').grid(row = 1, column = 0, padx = 5, pady = 5, sticky = W)
        self.Label_Blank = ttk.Label(self.length_frame, text = '').grid(row = 1, column = 1, padx = 5, pady = 5, sticky = E)
        self.Label_To2 = ttk.Label(self.length_frame, text = 'to').grid(row = 2, column = 1, padx = 5, pady = 5, sticky = E)
        self.Label_To = ttk.Label(self.length_frame, text = 'to').grid(row = 3, column = 1, padx = 5, pady = 5, sticky = E)

        #Entry Boxes
        self.Text_Length_Left = StringVar()
        self.Entry_Length_Left = ttk.Entry(self.length_frame, textvariable = self.Text_Length_Left,width = 13)
        self.Entry_Length_Left.grid(row = 3, column = 0, padx = 5, pady = 5)

        self.Text_Length_Right = StringVar()
        self.Entry_Length_Right = ttk.Entry(self.length_frame, textvariable = self.Text_Length_Right,width = 13, state='readonly')
        self.Entry_Length_Right.grid(row = 3, column = 2, padx = 5, pady = 5)
        def calculate_button(self):
            c_l = self.measurements.get()
            c_r = self.measurements1.get()
            e_l = self.Text_Length_Left.get()
            e_r = self.Text_Length_Right.get()

            c = Logic(c_l,c_r,e_l,e_r)

            self.Text_Length_Right.set('')
            self.Text_Length_Right.set(c.calulate())

        #Button
        self.Convert_Button = ttk.Button(self.length_frame, text = 'Convert',command = calculate_button, width = 10).grid(row = 1, column = 2, sticky = S)









def main():
root = Tk()
app = GUI(root)
root.title('Metric Calculator')
root.resizable(False,False)
root.mainloop()
.stackoverflow::before {
    font-family: 'FontAwesome';
    content: "\f16c ";
}

我们可以添加<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css"> <a class="stack-link stackoverflow" href="http://stackoverflow.com">StackOverflow</a>选择器和::before属性的空格吗?

2 个答案:

答案 0 :(得分:2)

是的,你可以添加像content: "\f16c \00a0";

这样的空格

Jsfiddle

\00a0是用于content属性的非中断空格的十六进制代码。 More Info

希望有所帮助:)

答案 1 :(得分:0)

是的,请使用\a0 &nbsp;或不间断的空格。

&#13;
&#13;
.stackoverflow::before {
    font-family: 'FontAwesome';
    content: "\f16c\a0\a0\a0\a0\a0\a0";
}
&#13;
<html>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
  <a class="stack-link stackoverflow" href="http://stackoverflow.com">StackOverflow</a>
</html>
&#13;
&#13;
&#13;