如果设置为' normal'?

时间:2016-08-23 12:41:47

标签: jquery css

我有这个:

<p id="p1" style="line-height:normal">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, 
    sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>

我需要增加行高一个像素。 如果设置为&#39; normal&#39;?

,如何获得绝对行高
ar lh=$('#paraph').css('line-height');

2 个答案:

答案 0 :(得分:0)

如果您可以将行高更改为100%并尝试此操作:

HTML:

var lh = $('#p1').css('line-height');
$('#p1').css('line-height', parseFloat(lh, 10) + 1 + 'px');

jQuery的:

    URL url;
    StringBuilder sb = new StringBuilder();
    sb.append("");
    try {
        url = new URL("URL");
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("POST");
        conn.setUseCaches(false);
        conn.setDoInput(true);

        conn.setRequestProperty("X-Auth-Token", _accessToken);

        conn.setDoOutput(true);
        OutputStream os = conn.getOutputStream();
        BufferedWriter writer = new BufferedWriter(
                new OutputStreamWriter(os, "UTF-8"));

        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("Id",idTosend));

        writer.write(getQuery(params));
        writer.flush();
        writer.close();
        os.close();

        conn.connect();

        STATUS = conn.getResponseCode();

        if(STATUS == 200 || STATUS == 201)
            reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        else
            reader = new BufferedReader(new InputStreamReader(conn.getErrorStream()));

        String line = null;
        while ((line = reader.readLine()) != null) {
            sb.append(line + "");
        }

        Log.e(TAG, "response: " + sb.toString());

    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }


private String getQuery(List<NameValuePair> params) throws     UnsupportedEncodingException{
    StringBuilder result = new StringBuilder();
    boolean first = true;

    for (NameValuePair pair : params)
    {
        if (first)
            first = false;
        else
            result.append("&");

        result.append(URLEncoder.encode(pair.getName(), "UTF-8"));
        result.append("=");
        result.append(URLEncoder.encode(pair.getValue(), "UTF-8"));
    }

    return result.toString();
}

https://jsfiddle.net/7yf43j43/8/

答案 1 :(得分:0)

好的,最后我写了这段代码,它在chrome

中正常工作
$('#lineHeightInc')
    .click(function() {
        var box = GetSelectedBox();
        var ct = box.data('LineHeight');
        if (isNaN(ct))
            ct = 0;
        ct++;
        box.css('line-height', (parseFloat(box.css('font-size')) * 1.61 + ct) + 'px');
        box.data('LineHeight', ct);
    });
$('#lineHeightDic')
    .click(function () {
        var box = GetSelectedBox();
        var ct = box.data('LineHeight');
        if (isNaN(ct))
            ct = 0;
        ct--;
        box.css('line-height', (parseFloat(box.css('font-size')) * 1.61 + ct) + 'px');
        box.data('LineHeight', ct);
    });

如果有任何人有更好的解决方案,我很乐意知道。