2014-10-28 95 views
-2

我需要自定義條碼的寬度。 我有嘗試使用此,我已使用jquery-barcode.js插件。(http://www.jqueryscript.net/other/Simple-jQuery-Based-Barcode-Generator-Barcode.html如何在html中更改條碼的寬度

$("#barcodeView").barcode(
"123456789023F", // Value barcode (dependent on the type of barcode) 
"code128", // type (string) 
{ barWidth: 1, barHeight: 50 } 
); 

但它被定製單個條的寬度和高度。我需要調整整個條形碼的widt和高度。這是我的HTML

<div class="col-xs-12 col-md-6" > 
       <div id="barcodeView"></div> 
      </div> 
+0

哪個插件是'barcode'?鏈接? – 2014-10-28 07:42:15

+0

jQuery的barcode.js – Saranga 2014-10-28 07:43:24

+0

http://www.jqueryscript.net/other/Simple-jQuery-Based-Barcode-Generator-Barcode.html – Saranga 2014-10-28 07:49:45

回答

2

我只是通過demo page要爲您所使用的插件。條形碼由幾個divs組成,代表單個條形,因此整個容器即div帶有「barcodeTarget」標識,但無法調整大小以適應您的需求。你可以明確地設置它的width,但它不會像你想要的那樣'調整'整個條形碼。

但是,barWidthbarHeight屬性只是代表單個條的所有divs的寬度和高度(以像素爲單位)。因此,您可以將這些屬性設置爲任何內容並相應地調整整個條形碼的大小。你可以像我提到的那樣明顯地限制容器的寬度,但它不會影響條形碼中條形的寬度。我希望它能讓你開始朝正確的方向發展。

0

也許你只需要指定對象#Barcode的寬度,你可以添加一些CSS:

<style> 
#Barconde { 
    width:200px; 
} 
</style> 

,我認爲它應該工作,但我不知道條碼API。

+0

我需要使用什麼ID,這是我的HTML

Saranga 2014-10-28 07:52:58

+0

你只要使用我的代碼,與您的Barecode的ID:** barcodeView ** – 2014-10-28 07:58:51

0

如果你需要增加整個條碼的寬度,這將反正

<style> 
    #barcodeView{ 
     width:200px !important; 
     } 
</style> 
+0

也看看這個鏈接https://code.google.com/p/jquery-barcode/source/browse/trunk/jquery-barcode /demo/demo.html?r=11 – 2014-10-28 07:59:20

0

工作,你需要增加每個巴(barWidth中設置)的寬度。

您可以在下面的設置,定製:

var settings = { 
     output:renderer, 
     bgColor: $("#bgColor").val(), 
     color: $("#color").val(), 
     barWidth: $("#barWidth").val(), 
     barHeight: $("#barHeight").val(), 
     moduleSize: $("#moduleSize").val(), 
     posX: $("#posX").val(), 
     posY: $("#posY").val(), 
     addQuietZone: $("#quietZoneSize").val() 
    }; 
+0

但我使用1作爲寬度。 – Saranga 2014-10-28 08:02:52

+0

@SarangaSachinthana在這種情況下可以請創建一個小提琴?並分享它! – 2014-10-28 09:21:57

1

試試這個

<div class="col-xs-12 col-md-6" > 
      <div id="barcodeView" style="width:200px;"></div> 
     </div> 

OR

<style> 
    #barcodeView{ 
     width:12.5em; 

     } 

    </style>